Logging update
Add SFT logs to logbase
This commit is contained in:
parent
171baefc0c
commit
9abc1d643a
2 changed files with 43 additions and 23 deletions
|
@ -185,7 +185,35 @@
|
||||||
{"PM001",
|
{"PM001",
|
||||||
{info, "Indexed new cache entry with total L0 cache size now ~w"}},
|
{info, "Indexed new cache entry with total L0 cache size now ~w"}},
|
||||||
{"PM002",
|
{"PM002",
|
||||||
{info, "Completed dump of L0 cache to list of size ~w"}}
|
{info, "Completed dump of L0 cache to list of size ~w"}},
|
||||||
|
|
||||||
|
|
||||||
|
{"SFT01",
|
||||||
|
{info, "Opened filename with name ~s"}},
|
||||||
|
{"SFT02",
|
||||||
|
{info, "File ~s has been set for delete"}},
|
||||||
|
{"SFT03",
|
||||||
|
{info, "File creation of L0 file ~s"}},
|
||||||
|
{"SFT04",
|
||||||
|
{info, "File ~s prompting for delete status check"}},
|
||||||
|
{"SFT05",
|
||||||
|
{info, "Exit called for reason ~w on filename ~s"}},
|
||||||
|
{"SFT06",
|
||||||
|
{info, "Exit called and now clearing ~s"}},
|
||||||
|
{"SFT07",
|
||||||
|
{info, "Creating file with input of size ~w"}},
|
||||||
|
{"SFT08",
|
||||||
|
{info, "Renaming file from ~s to ~s"}},
|
||||||
|
{"SFT09",
|
||||||
|
{warn, "Filename ~s already exists"}},
|
||||||
|
{"SFT10",
|
||||||
|
{warn, "Rename rogue filename ~s to ~s"}},
|
||||||
|
{"SFT11",
|
||||||
|
{error, "Segment filter failed due to ~s"}},
|
||||||
|
{"SFT12",
|
||||||
|
{error, "Segment filter failed due to CRC check ~w did not match ~w"}},
|
||||||
|
{"SFT13",
|
||||||
|
{error, "Segment filter failed due to ~s"}}
|
||||||
|
|
||||||
])).
|
])).
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,7 @@ handle_call({sft_new, Filename, KL1, KL2, LevelR}, _From, _State) ->
|
||||||
end;
|
end;
|
||||||
handle_call({sft_open, Filename}, _From, _State) ->
|
handle_call({sft_open, Filename}, _From, _State) ->
|
||||||
{_Handle, FileMD} = open_file(#state{filename=Filename}),
|
{_Handle, FileMD} = open_file(#state{filename=Filename}),
|
||||||
io:format("Opened filename with name ~s~n", [Filename]),
|
leveled_log:log("SFT01", [Filename]),
|
||||||
{reply,
|
{reply,
|
||||||
{ok,
|
{ok,
|
||||||
{FileMD#state.smallest_key, FileMD#state.highest_key}},
|
{FileMD#state.smallest_key, FileMD#state.highest_key}},
|
||||||
|
@ -343,7 +343,7 @@ handle_call(background_complete, _From, State) ->
|
||||||
State}
|
State}
|
||||||
end;
|
end;
|
||||||
handle_call({set_for_delete, Penciller}, _From, State) ->
|
handle_call({set_for_delete, Penciller}, _From, State) ->
|
||||||
io:format("File ~s has been set for delete~n", [State#state.filename]),
|
leveled_log:log("SFT02", [State#state.filename]),
|
||||||
{reply,
|
{reply,
|
||||||
ok,
|
ok,
|
||||||
State#state{ready_for_delete=true,
|
State#state{ready_for_delete=true,
|
||||||
|
@ -356,8 +356,7 @@ handle_cast({sft_newfroml0cache, Filename, Slots, FetchFun}, _State) ->
|
||||||
SW = os:timestamp(),
|
SW = os:timestamp(),
|
||||||
Inp1 = leveled_pmem:to_list(Slots, FetchFun),
|
Inp1 = leveled_pmem:to_list(Slots, FetchFun),
|
||||||
{ok, State} = create_levelzero(Inp1, Filename),
|
{ok, State} = create_levelzero(Inp1, Filename),
|
||||||
io:format("File creation of L0 file ~s took ~w microseconds~n",
|
leveled_log:log_timer("SFT03", [Filename], SW),
|
||||||
[Filename, timer:now_diff(os:timestamp(), SW)]),
|
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
handle_cast(close, State) ->
|
handle_cast(close, State) ->
|
||||||
{stop, normal, State}.
|
{stop, normal, State}.
|
||||||
|
@ -365,8 +364,7 @@ handle_cast(close, State) ->
|
||||||
handle_info(timeout, State) ->
|
handle_info(timeout, State) ->
|
||||||
case State#state.ready_for_delete of
|
case State#state.ready_for_delete of
|
||||||
true ->
|
true ->
|
||||||
io:format("File ~s prompting for delete status check~n",
|
leveled_log:log("SFT05", [State#state.filename]),
|
||||||
[State#state.filename]),
|
|
||||||
ok = leveled_penciller:pcl_confirmdelete(State#state.penciller,
|
ok = leveled_penciller:pcl_confirmdelete(State#state.penciller,
|
||||||
State#state.filename),
|
State#state.filename),
|
||||||
{noreply, State, ?DELETE_TIMEOUT};
|
{noreply, State, ?DELETE_TIMEOUT};
|
||||||
|
@ -375,12 +373,10 @@ handle_info(timeout, State) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
terminate(Reason, State) ->
|
terminate(Reason, State) ->
|
||||||
io:format("Exit called for reason ~w on filename ~s~n",
|
leveled_log:log("SFT05", [Reason, State#state.filename]),
|
||||||
[Reason, State#state.filename]),
|
|
||||||
case State#state.ready_for_delete of
|
case State#state.ready_for_delete of
|
||||||
true ->
|
true ->
|
||||||
io:format("Exit called and now clearing ~s~n",
|
leveled_log:log("SFT06", [State#state.filename]),
|
||||||
[State#state.filename]),
|
|
||||||
ok = file:close(State#state.handle),
|
ok = file:close(State#state.handle),
|
||||||
ok = case filelib:is_file(State#state.filename) of
|
ok = case filelib:is_file(State#state.filename) of
|
||||||
true ->
|
true ->
|
||||||
|
@ -418,7 +414,7 @@ create_levelzero(ListForFile, Filename) ->
|
||||||
{TmpFilename, PrmFilename} = generate_filenames(Filename),
|
{TmpFilename, PrmFilename} = generate_filenames(Filename),
|
||||||
{Handle, FileMD} = create_file(TmpFilename),
|
{Handle, FileMD} = create_file(TmpFilename),
|
||||||
InputSize = length(ListForFile),
|
InputSize = length(ListForFile),
|
||||||
io:format("Creating file with input of size ~w~n", [InputSize]),
|
leveled_log:log("SFT07", [InputSize]),
|
||||||
Rename = {true, TmpFilename, PrmFilename},
|
Rename = {true, TmpFilename, PrmFilename},
|
||||||
{ReadHandle,
|
{ReadHandle,
|
||||||
UpdFileMD,
|
UpdFileMD,
|
||||||
|
@ -451,7 +447,7 @@ generate_filenames(RootFilename) ->
|
||||||
%% Start a bare file with an initial header and no further details
|
%% Start a bare file with an initial header and no further details
|
||||||
%% Return the {Handle, metadata record}
|
%% Return the {Handle, metadata record}
|
||||||
create_file(FileName) when is_list(FileName) ->
|
create_file(FileName) when is_list(FileName) ->
|
||||||
io:format("Opening file with filename ~s~n", [FileName]),
|
leveled_log:log("SFT01", [FileName]),
|
||||||
ok = filelib:ensure_dir(FileName),
|
ok = filelib:ensure_dir(FileName),
|
||||||
{ok, Handle} = file:open(FileName, [binary, raw, read, write]),
|
{ok, Handle} = file:open(FileName, [binary, raw, read, write]),
|
||||||
Header = create_header(initial),
|
Header = create_header(initial),
|
||||||
|
@ -529,16 +525,14 @@ complete_file(Handle, FileMD, KL1, KL2, LevelR, Rename) ->
|
||||||
{ReadHandle, UpdFileMD, KeyRemainders}.
|
{ReadHandle, UpdFileMD, KeyRemainders}.
|
||||||
|
|
||||||
rename_file(OldName, NewName) ->
|
rename_file(OldName, NewName) ->
|
||||||
io:format("Renaming file from ~s to ~s~n", [OldName, NewName]),
|
leveled_log:log("SFT08", [OldName, NewName]),
|
||||||
case filelib:is_file(NewName) of
|
case filelib:is_file(NewName) of
|
||||||
true ->
|
true ->
|
||||||
io:format("Filename ~s already exists~n",
|
leveled_log:log("SFT09", [NewName]),
|
||||||
[NewName]),
|
|
||||||
AltName = filename:join(filename:dirname(NewName),
|
AltName = filename:join(filename:dirname(NewName),
|
||||||
filename:basename(NewName))
|
filename:basename(NewName))
|
||||||
++ ?DISCARD_EXT,
|
++ ?DISCARD_EXT,
|
||||||
io:format("Rename rogue filename ~s to ~s~n",
|
leveled_log:log("SFT10", [NewName, AltName]),
|
||||||
[NewName, AltName]),
|
|
||||||
ok = file:rename(NewName, AltName);
|
ok = file:rename(NewName, AltName);
|
||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
|
@ -1257,7 +1251,7 @@ check_for_segments(SegFilter, SegmentList, CRCCheck) ->
|
||||||
[0, 0, 0, 0],
|
[0, 0, 0, 0],
|
||||||
0, Count, []) of
|
0, Count, []) of
|
||||||
{error_so_maybe_present, Reason} ->
|
{error_so_maybe_present, Reason} ->
|
||||||
io:format("Segment filter failed due to ~s~n", [Reason]),
|
leveled_log:log("SFT11", [Reason]),
|
||||||
error_so_maybe_present;
|
error_so_maybe_present;
|
||||||
{OutputCheck, BlockList} when OutputCheck == CheckSum,
|
{OutputCheck, BlockList} when OutputCheck == CheckSum,
|
||||||
BlockList == [] ->
|
BlockList == [] ->
|
||||||
|
@ -1265,9 +1259,7 @@ check_for_segments(SegFilter, SegmentList, CRCCheck) ->
|
||||||
{OutputCheck, BlockList} when OutputCheck == CheckSum ->
|
{OutputCheck, BlockList} when OutputCheck == CheckSum ->
|
||||||
{maybe_present, BlockList};
|
{maybe_present, BlockList};
|
||||||
{OutputCheck, _} ->
|
{OutputCheck, _} ->
|
||||||
io:format("Segment filter failed due to CRC check~n
|
leveled_log:log("SFT12", [OutputCheck, CheckSum]),
|
||||||
~w did not match ~w~n",
|
|
||||||
[OutputCheck, CheckSum]),
|
|
||||||
error_so_maybe_present
|
error_so_maybe_present
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
|
@ -1276,7 +1268,7 @@ check_for_segments(SegFilter, SegmentList, CRCCheck) ->
|
||||||
lists:max(SegmentList),
|
lists:max(SegmentList),
|
||||||
0, Count, []) of
|
0, Count, []) of
|
||||||
{error_so_maybe_present, Reason} ->
|
{error_so_maybe_present, Reason} ->
|
||||||
io:format("Segment filter failed due to ~s~n", [Reason]),
|
leveled_log:log("SFT13", [Reason]),
|
||||||
error_so_maybe_present;
|
error_so_maybe_present;
|
||||||
BlockList when BlockList == [] ->
|
BlockList when BlockList == [] ->
|
||||||
not_present;
|
not_present;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue