瀏覽代碼

fx: 代码整理

master
SisMaker 3 年之前
父節點
當前提交
5e805b996f
共有 9 個文件被更改,包括 62 次插入63 次删除
  1. +4
    -4
      src/backend/lgBkdConsole.erl
  2. +8
    -9
      src/backend/lgBkdFile.erl
  3. +1
    -1
      src/backend/lgBkdThrottle.erl
  4. +9
    -9
      src/crashLog/lgCrashLog.erl
  5. +2
    -2
      src/eLog.erl
  6. +2
    -2
      src/eLog_app.erl
  7. +22
    -22
      src/errLogger/lgErrLoggerH.erl
  8. +6
    -6
      src/formatter/lgFmtTer.erl
  9. +8
    -8
      src/watcher/lgHWatcherSrv.erl

+ 4
- 4
src/backend/lgBkdConsole.erl 查看文件

@ -12,7 +12,7 @@
-compile(inline).
-compile({inline_size, 128}).
-define(TERSE_FORMAT, [datetime, <<" ">>, color, sev, <<" ">>, message]).
-define(TERSE_FORMAT, [datetime, color, sev, message]).
-define(LgDefConsoleFmtCfg, ?TERSE_FORMAT ++ [eol()]).
-define(LgDefConsoleOpts, [{use_stderr, false}, {group_leader, false}, {id, ?MODULE}, {fmtTer, ?LgDefFmtTer}, {fmtCfg, ?LgDefConsoleFmtCfg}]).
@ -86,7 +86,7 @@ handleCall({mSetLogLevel, Level}, State) ->
handleCall({mRotate, _}, State) ->
{reply, ok, State};
handleCall(_Msg, State) ->
?ERR("~p call receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p call receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
{reply, ok, State}.
handleEvent({mWriteLog, Message}, #state{level = Level, out = Out, fmtTer = FmtTer, fmtCfg = FmtCfg, colors = Colors, id = ID}) ->
@ -98,7 +98,7 @@ handleEvent({mWriteLog, Message}, #state{level = Level, out = Out, fmtTer = FmtT
kpS
end;
handleEvent(_Msg, _State) ->
?ERR("~p event receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p event receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
kpS.
handleInfo({'DOWN', _, process, Out, _}, #state{out = Out}) ->
@ -106,7 +106,7 @@ handleInfo({'DOWN', _, process, Out, _}, #state{out = Out}) ->
handleInfo({mRotate, _}, _State) ->
kpS;
handleInfo(_Msg, _State) ->
?ERR("~p info receive unexpect msg ~p ~n", [?MODULE, _Msg]),
?ERR(<<"~p info receive unexpect msg ~p ~n";>>;, [?MODULE, _Msg]),
kpS.
terminate(removeEpm, State) ->

+ 8
- 9
src/backend/lgBkdFile.erl 查看文件

@ -90,10 +90,9 @@ init(Opts) ->
case Rotator:createLogFile(FileName, {SyncSize, SyncInt}) of
{ok, Fd, Inode, CTime, _Size} ->
?INT_LOG(?error, "Failed to open log file ~ts 1111", [FileName]),
{ok, TemState#state{fd = Fd, inode = Inode, cTime = CTime}};
{error, Reason} ->
?INT_LOG(?error, "Failed to open log file ~ts with error ~s", [FileName, file:format_error(Reason)]),
?INT_LOG(?error, <<"Failed to open log file ~ts with error ~s";>>;, [FileName, file:format_error(Reason)]),
{ok, TemState#state{flap = true}}
end.
@ -104,7 +103,7 @@ handleCall({mSetLogLevel, Level}, #state{fBName = FBName} = State) ->
false ->
{reply, {error, bad_loglevel}, State};
LevelMask ->
?INT_LOG(?notice, "Changed loglevel of ~s to ~p", [FBName, Level]),
?INT_LOG(?notice, <<"Changed loglevel of ~s to ~p";>>;, [FBName, Level]),
{reply, ok, State#state{level = LevelMask}}
end;
@ -114,14 +113,14 @@ handleCall({mSetLogHwm, Hwm}, #state{shaper = Shaper, fBName = FBName} = State)
{reply, {error, badHwm}, State};
_ ->
NewShaper = Shaper#lgShaper{hwm = Hwm},
?INT_LOG(?notice, "Changed loghwm of ~ts to ~p", [FBName, Hwm]),
?INT_LOG(?notice, <<"Changed loghwm of ~ts to ~p";>>;, [FBName, Hwm]),
{reply, {lastHwm, Shaper#lgShaper.hwm}, State#state{shaper = NewShaper}}
end;
handleCall(mRotate, State = #state{fBName = FBName}) ->
{ok, NewState} = handleInfo({mRotate, FBName}, State),
{reply, ok, NewState};
handleCall(_Msg, State) ->
?ERR("~p call receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p call receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
{reply, ok, State}.
handleEvent({mWriteLog, Message}, #state{fBName = FBName, level = Level, shaper = Shaper, fmtTer = FmtTer, fmtCfg = FmtCfg} = State) ->
@ -151,7 +150,7 @@ handleEvent({mWriteLog, Message}, #state{fBName = FBName, level = Level, shaper
kpS
end;
handleEvent(_Msg, _State) ->
?ERR("~p event receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p event receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
kpS.
handleInfo({mRotate, FBName}, #state{fBName = FBName, date = Date} = State) ->
@ -171,7 +170,7 @@ handleInfo({mShaperExpired, FBName}, #state{shaper = Shaper, fBName = FBName, fm
end,
{ok, State#state{shaper = Shaper#lgShaper{dropped = 0}}};
handleInfo(_Msg, _State) ->
?ERR("~p info receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p info receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
kpS.
terminate(_Reason, State) ->
@ -199,7 +198,7 @@ writeLog(#state{fileName = FileName, fd = Fd, inode = Inode, cTime = CTime, flap
writeFile(NewState, Level, Msg)
end;
{error, Reason} ->
?IIF(Flap, State, begin ?INT_LOG(?error, "Failed to reopen log file ~ts with error ~s", [FileName, file:format_error(Reason)]), State#state{flap = true} end)
?IIF(Flap, State, begin ?INT_LOG(?error, <<"Failed to reopen log file ~ts with error ~s";>>;, [FileName, file:format_error(Reason)]), State#state{flap = true} end)
end;
_ ->
writeFile(State, Level, Msg)
@ -214,7 +213,7 @@ writeFile(#state{fd = Fd, fileName = FileName, flap = Flap, syncOn = SyncOn} = S
NewFlap =
case file:datasync(Fd) of
{error, Reason} when Flap == false ->
?INT_LOG(?error, "Failed to write log message to file ~ts: ~s", [FileName, file:format_error(Reason)]),
?INT_LOG(?error, <<"Failed to write log message to file ~ts: ~s";>>;, [FileName, file:format_error(Reason)]),
true;
ok ->
false;

+ 1
- 1
src/backend/lgBkdThrottle.erl 查看文件

@ -36,7 +36,7 @@ handleCall(mGetLogLevel, State) ->
handleCall({mSetLogLevel, _Level}, State) ->
{reply, ok, State};
handleCall(_Msg, State) ->
?ERR("~p call receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p call receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
{reply, ok, State}.
handleEvent({mWriteLog, _Message}, #state{hwm = Hwm, window = Window, async = Async} = State) ->

+ 9
- 9
src/crashLog/lgCrashLog.erl 查看文件

@ -58,7 +58,7 @@ init({FBName, MaxFmtSize, MaxFileSize, CfgDate, Count, Rotator}) ->
scheduleRotation(Date),
{ok, #state{fileName = Filename, fBName = FBName, fd = Fd, inode = Inode, cTime = CTime, maxFmtSize = MaxFmtSize, maxFileSize = MaxFileSize, date = Date, count = Count, rotator = Rotator}};
{error, Reason} ->
?INT_LOG(?error, "Failed to open crash log file ~ts with error: ~s", [Filename, file:format_error(Reason)]),
?INT_LOG(?error, <<"Failed to open crash log file ~ts with error: ~s";>>;, [Filename, file:format_error(Reason)]),
{ok, #state{fileName = Filename, fBName = FBName, maxFmtSize = MaxFmtSize, maxFileSize = MaxFileSize, date = Date, count = Count, flap = true, rotator = Rotator}}
end.
@ -66,11 +66,11 @@ handleCall({mWriteLog, Event}, State, _From) ->
{Reply, NewState} = writeLog(Event, State),
{reply, Reply, NewState};
handleCall(_Msg, _State, _From) ->
?ERR("~p call receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p call receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
{reply, ok}.
handleCast(_Msg, _State) ->
?ERR("~p cast receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p cast receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
kpS.
handleInfo({mWriteLog, Event}, State) ->
@ -81,7 +81,7 @@ handleInfo(mRotate, #state{date = Date} = State) ->
scheduleRotation(Date),
{ok, NewState};
handleInfo(_Msg, _State) ->
?ERR("~p info receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p info receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
kpS.
terminate(_Reason, _State) ->
@ -147,11 +147,11 @@ saslLimitedStr(progress, Report, FmtMaxBytes) ->
[
begin
BinStr = eFmt:formatBin(<<"~p">>, [Data], [{charsLimit, FmtMaxBytes}]),
eFmt:formatBin(" ~16w: ~s~n", [Tag, BinStr])
eFmt:formatBin(<<" ~16w: ~s~n";>>;, [Tag, BinStr])
end || {Tag, Data} <- Report
];
saslLimitedStr(crash_report, Report, FmtMaxBytes) ->
eFmt:formatBin("~p~n", [Report], [{charsLimit, FmtMaxBytes}]).
eFmt:formatBin(<<"~p~n";>>;, [Report], [{charsLimit, FmtMaxBytes}]).
writeLog(Event, #state{fileName = FileName, fd = FD, inode = Inode, cTime = CTime, flap = Flap, maxFmtSize = FmtMaxBytes, maxFileSize = RotSize, rotator = Rotator} = State) ->
%% borrowed from riak_err
@ -180,10 +180,10 @@ writeLog(Event, #state{fileName = FileName, fd = FD, inode = Inode, cTime = CTim
TimeBinStr = lgUtil:msToBinStr(),
Time = [TimeBinStr, <<" =">>, ReportStr, <<"====\n">>],
NodeSuffix = otherNodeSuffix(Pid),
Msg = eFmt:formatBin("~s~s~s", [Time, MsgStr, NodeSuffix]),
Msg = eFmt:formatBin(<<"~s~s~s";>>;, [Time, MsgStr, NodeSuffix]),
case file:write(NewFD, unicode:characters_to_binary(Msg)) of
{error, Reason} when Flap == false ->
?INT_LOG(?error, "Failed to write log message to file ~ts: ~s", [FileName, file:format_error(Reason)]),
?INT_LOG(?error, <<"Failed to write log message to file ~ts: ~s";>>;, [FileName, file:format_error(Reason)]),
{ok, State#state{fd = NewFD, inode = NewInode, cTime = NewCTime, flap = true}};
ok ->
{ok, State#state{fd = NewFD, inode = NewInode, cTime = NewCTime, flap = false}};
@ -192,7 +192,7 @@ writeLog(Event, #state{fileName = FileName, fd = FD, inode = Inode, cTime = CTim
end
end;
{error, Reason} ->
?IIF(Flap, {ok, State}, begin ?INT_LOG(?error, "Failed to reopen crash log ~ts with error: ~s", [FileName, file:format_error(Reason)]), {ok, State#state{flap = true}} end)
?IIF(Flap, {ok, State}, begin ?INT_LOG(?error, <<"Failed to reopen crash log ~ts with error: ~s";>>;, [FileName, file:format_error(Reason)]), {ok, State#state{flap = true}} end)
end
end.

+ 2
- 2
src/eLog.erl 查看文件

@ -236,11 +236,11 @@ parseStack(Stacktrace) ->
begin
case Location of
[] ->
<<" ", (atom_to_binary(Mod, utf8))/binary, ":", (atom_to_binary(Func, utf8))/binary, "(", (eFmt:formatBin("~w", [Arity]))/binary, ")\n">>;
<<" ", (atom_to_binary(Mod, utf8))/binary, ":", (atom_to_binary(Func, utf8))/binary, "(", (eFmt:formatBin(<<"~w";>>;, [Arity]))/binary, ")\n">>;
[{file, File}, {line, Line}] ->
<<" ", (atom_to_binary(Mod, utf8))/binary, ":", (atom_to_binary(Func, utf8))/binary, "/", (integer_to_binary(Arity))/binary, "(", (unicode:characters_to_binary(File))/binary, ":", (integer_to_binary(Line))/binary, ")\n">>;
_ ->
<<" ", (atom_to_binary(Mod, utf8))/binary, ":", (atom_to_binary(Func, utf8))/binary, "(", (eFmt:formatBin("~w", [Arity]))/binary, ")", (eFmt:formatBin("~w", [Location]))/binary, "\n">>
<<" ", (atom_to_binary(Mod, utf8))/binary, ":", (atom_to_binary(Func, utf8))/binary, "(", (eFmt:formatBin(<<"~w";>>;, [Arity]))/binary, ")", (eFmt:formatBin(<<"~w";>>;, [Location]))/binary, "\n">>
end
end || {Mod, Func, Arity, Location} <- Stacktrace
>>.

+ 2
- 2
src/eLog_app.erl 查看文件

@ -121,7 +121,7 @@ doStartHandlers([OneHandler | Handlers], Sink, NameAcc, HandlerAcc) ->
{lgBkFile, F} ->
case lists:member(F, NameAcc) of
true ->
error_logger:error_msg("Cannot have same file (~p) in multiple file backends~n", [F]),
error_logger:error_msg(<<"Cannot have same file (~p) in multiple file backends~n";>>;, [F]),
throw({error, bad_config});
_ ->
[F | NameAcc]
@ -173,7 +173,7 @@ tryRemoveLoggerHandler() ->
catch
error:undef -> ok;
Err:Reason ->
error_logger:error_msg("calling logger:remove_handler(default) failed: ~p ~p", [Err, Reason])
error_logger:error_msg(<<"calling logger:remove_handler(default) failed: ~p ~p";>>;, [Err, Reason])
end.
parseHandlers([]) ->

+ 22
- 22
src/errLogger/lgErrLoggerH.erl 查看文件

@ -104,7 +104,7 @@ handle_event(Event, #state{sink = Sink, shaper = Shaper} = State) ->
true ->
{ok, State#state{shaper = NewShaper}};
_ ->
?LOGFMT(Sink, ?warning, self(), "lgErrLoggerH dropped ~p messages in the last second that exceeded the limit of ~p messages/sec", [Drop, NewShaper#lgShaper.hwm]),
?LOGFMT(Sink, ?warning, self(), <<"lgErrLoggerH dropped ~p messages in the last second that exceeded the limit of ~p messages/sec";>>;, [Drop, NewShaper#lgShaper.hwm]),
evalGl(Event, State#state{shaper = NewShaper})
end;
{false, _, NewShaper} ->
@ -116,7 +116,7 @@ handle_info({mShaperExpired, ?MODULE}, #state{sink = Sink, shaper = Shaper} = St
0 ->
ignore;
Dropped ->
?LOGFMT(Sink, ?warning, self(), "lgErrLoggerH dropped ~p messages in the last second that exceeded the limit of ~p messages/sec", [Dropped, Shaper#lgShaper.hwm])
?LOGFMT(Sink, ?warning, self(), <<"lgErrLoggerH dropped ~p messages in the last second that exceeded the limit of ~p messages/sec";>>;, [Dropped, Shaper#lgShaper.hwm])
end,
{ok, State#state{shaper = Shaper#lgShaper{dropped = 0}}};
handle_info(_Info, State) ->
@ -186,7 +186,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
end,
?CRASH_LOG(Event),
{Md, Formatted} = formatReasonMd(Reason),
?LOGFMT(Sink, ?error, [{pid, Pid}, {name, Name} | Md], "gen_server ~w terminated with reason: ~s", [Name, Formatted]);
?LOGFMT(Sink, ?error, [{pid, Pid}, {name, Name} | Md], <<"gen_server ~w terminated with reason: ~s";>>;, [Name, Formatted]);
"** gen_ipc State machine " ++ _ ->
%% gen_server terminate
{Reason, Name} =
@ -203,7 +203,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
end,
?CRASH_LOG(Event),
{Md, Formatted} = formatReasonMd(Reason),
?LOGFMT(Sink, ?error, [{pid, Pid}, {name, Name} | Md], "gen_ipc ~w terminated with reason: ~s", [Name, Formatted]);
?LOGFMT(Sink, ?error, [{pid, Pid}, {name, Name} | Md], <<"gen_ipc ~w terminated with reason: ~s";>>;, [Name, Formatted]);
"** State machine " ++ _ ->
%% Check if the terminated process is gen_fsm or gen_statem
%% since they generate the same exit message
@ -226,13 +226,13 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
end,
{Md, Formatted} = formatReasonMd(Reason),
?CRASH_LOG(Event),
?LOGFMT(Sink, ?error, [{pid, Pid}, {name, Name} | Md], "~s ~w in state ~w terminated with reason: ~s", [Type, Name, StateName, Formatted]);
?LOGFMT(Sink, ?error, [{pid, Pid}, {name, Name} | Md], <<"~s ~w in state ~w terminated with reason: ~s";>>;, [Type, Name, StateName, Formatted]);
"** gen_event handler" ++ _ ->
%% gen_event handler terminate
[ID, Name, _Msg, _State, Reason] = Args,
{Md, Formatted} = formatReasonMd(Reason),
?CRASH_LOG(Event),
?LOGFMT(Sink, ?error, [{pid, Pid}, {name, Name} | Md], "gen_event ~w installed in ~w terminated with reason: ~s", [ID, Name, Formatted]);
?LOGFMT(Sink, ?error, [{pid, Pid}, {name, Name} | Md], <<"gen_event ~w installed in ~w terminated with reason: ~s";>>;, [ID, Name, Formatted]);
"** Cowboy handler" ++ _ ->
%% Cowboy HTTP server error
?CRASH_LOG(Event),
@ -240,14 +240,14 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
[Module, Function, Arity, _Request, _State] ->
%% we only get the 5-element list when its a non-exported function
?LOGFMT(Sink, ?error, Pid,
"Cowboy handler ~p terminated with reason: call to undefined function ~p:~p/~p",
<<"Cowboy handler ~p terminated with reason: call to undefined function ~p:~p/~p";>>;,
[Module, Module, Function, Arity]);
[Module, Function, Arity, _Class, Reason | Tail] ->
%% any other cowboy error_format list *always* ends with the stacktrace
StackTrace = lists:last(Tail),
{Md, Formatted} = formatReasonMd({Reason, StackTrace}),
?LOGFMT(Sink, ?error, [{pid, Pid} | Md],
"Cowboy handler ~p terminated in ~p:~p/~p with reason: ~s", [Module, Module, Function, Arity, Formatted])
<<"Cowboy handler ~p terminated in ~p:~p/~p with reason: ~s";>>;, [Module, Module, Function, Arity, Formatted])
end;
"Ranch listener " ++ _ ->
%% Ranch errors
@ -257,18 +257,18 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
[Ref, ConnectionPid, StreamID, RequestPid, Reason, StackTrace] ->
{Md, Formatted} = formatReasonMd({Reason, StackTrace}),
?LOGFMT(Sink, ?error, [{pid, RequestPid} | Md],
"Cowboy stream ~p with ranch listener ~p and connection process ~p "
"had its request process exit with reason: ~s", [StreamID, Ref, ConnectionPid, Formatted]);
<<"Cowboy stream ~p with ranch listener ~p and connection process ~p "
"had its request process exit with reason: ~s">>, [StreamID, Ref, ConnectionPid, Formatted]);
[Ref, _Protocol, Worker, {[{reason, Reason}, {mfa, {Module, Function, Arity}}, {stacktrace, StackTrace} | _], _}] ->
{Md, Formatted} = formatReasonMd({Reason, StackTrace}),
?LOGFMT(Sink, ?error, [{pid, Worker} | Md], "Ranch listener ~p terminated in ~p:~p/~p with reason: ~s", [Ref, Module, Function, Arity, Formatted]);
?LOGFMT(Sink, ?error, [{pid, Worker} | Md], <<"Ranch listener ~p terminated in ~p:~p/~p with reason: ~s";>>;, [Ref, Module, Function, Arity, Formatted]);
[Ref, _Protocol, Worker, Reason] ->
{Md, Formatted} = formatReasonMd(Reason),
?LOGFMT(Sink, ?error, [{pid, Worker} | Md], "Ranch listener ~p terminated with reason: ~s", [Ref, Formatted]);
?LOGFMT(Sink, ?error, [{pid, Worker} | Md], <<"Ranch listener ~p terminated with reason: ~s";>>;, [Ref, Formatted]);
[Ref, Protocol, Ret] ->
%% ranch_conns_sup.erl module line 119-123 has three parameters error msg, log it.
{Md, Formatted} = formatReasonMd(Ret),
?LOGFMT(Sink, ?error, [{pid, Protocol} | Md], "Ranch listener ~p terminated with result:~s", [Ref, Formatted])
?LOGFMT(Sink, ?error, [{pid, Protocol} | Md], <<"Ranch listener ~p terminated with result:~s";>>;, [Ref, Formatted])
end;
"webmachine error" ++ _ ->
%% Webmachine HTTP server error
@ -283,7 +283,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
Error
end,
{Md, Formatted} = formatReasonMd(StackTrace),
?LOGFMT(Sink, ?error, [{pid, Pid} | Md], "Webmachine error at path ~p : ~s", [Path, Formatted]);
?LOGFMT(Sink, ?error, [{pid, Pid} | Md], <<"Webmachine error at path ~p : ~s";>>;, [Path, Formatted]);
_ ->
?CRASH_LOG(Event),
?LOGFMT(Sink, ?error, Pid, Fmt, Args)
@ -302,7 +302,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
Offender = formatOffender(Off),
{Md, Formatted} = formatReasonMd(Reason),
?LOGFMT(Sink, ?error, [{pid, Pid} | Md],
"Supervisor ~w had child ~s exit with reason ~s in context ~w",
<<"Supervisor ~w had child ~s exit with reason ~s in context ~w";>>;,
[supervisorName(Name), Offender, Formatted, Ctx]);
_ ->
?LOGMSG(Sink, ?error, Pid, <<"SUPERVISOR REPORT ", (printSillyList(D))/binary>>)
@ -310,7 +310,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
{error_report, _GL, {Pid, crash_report, [Self, Neighbours]}} ->
?CRASH_LOG(Event),
{Md, Formatted} = formatCrashReport(Self, Neighbours),
?LOGMSG(Sink, ?error, [{pid, Pid} | Md], "CRASH REPORT " ++ Formatted);
?LOGMSG(Sink, ?error, [{pid, Pid} | Md], <<"CRASH REPORT ", Formatted/binary>>);
{warning_msg, _GL, {Pid, Fmt, Args}} ->
?LOGFMT(Sink, ?warning, Pid, Fmt, Args);
{warning_report, _GL, {Pid, std_warning, Report}} ->
@ -326,7 +326,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
no_log;
_ ->
{Md, Formatted} = formatReasonMd(Reason),
?LOGFMT(Sink, ?info, [{pid, Pid} | Md], "Application ~w exited with reason: ~s", [App, Formatted])
?LOGFMT(Sink, ?info, [{pid, Pid} | Md], <<"Application ~w exited with reason: ~s";>>;, [App, Formatted])
end;
_ ->
?LOGMSG(Sink, ?info, Pid, printSillyList(D))
@ -341,7 +341,7 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
true ->
no_log;
_ ->
?LOGFMT(Sink, ?info, P, "Application ~w started on node ~w", [App, Node])
?LOGFMT(Sink, ?info, P, <<"Application ~w started on node ~w";>>;, [App, Node])
end;
[{started, Started}, {supervisor, Name}] ->
case lgUtil:get_env(suppressSupStartStop, false) of
@ -350,14 +350,14 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
_ ->
MFA = formatMfa(get_value(mfargs, Started)),
Pid = get_value(pid, Started),
?LOGFMT(Sink, ?debug, P, "Supervisor ~w started ~s at pid ~w",
?LOGFMT(Sink, ?debug, P, <<"Supervisor ~w started ~s at pid ~w";>>;,
[supervisorName(Name), MFA, Pid])
end;
_ ->
?LOGMSG(Sink, ?info, P, <<"PROGRESS REPORT ", (printSillyList(D))/binary>>)
end;
_ ->
?LOGFMT(Sink, ?warning, self(), "Unexpected error_logger event ~w", [Event])
?LOGFMT(Sink, ?warning, self(), <<"Unexpected error_logger event ~w";>>;, [Event])
end,
case DidLog of
logged ->
@ -388,7 +388,7 @@ formatCrashReport(Report, Neighbours) ->
{Class, Reason, Trace} = get_value(error_info, Report),
{Md, ReasonStr} = formatReasonMd({Reason, Trace}),
Type = ?IIF(Class == exit, <<"exited">>, <<"crashed">>),
{Md0 ++ Md, eFmt:formatBin("Process ~w with ~w neighbours ~s with reason: ~s", [Name, length(Neighbours), Type, ReasonStr])}.
{Md0 ++ Md, eFmt:formatBin(<<"Process ~w with ~w neighbours ~s with reason: ~s";>>;, [Name, length(Neighbours), Type, ReasonStr])}.
formatOffender(Off) ->
case get_value(mfargs, Off) of
@ -499,7 +499,7 @@ formatReasonMd({{badarg, Stack}, _}) ->
formatReasonMd({{badarity, {Fun, Args}}, [MFA | _]}) ->
{arity, Arity} = lists:keyfind(arity, 1, erlang:fun_info(Fun)),
{Md, Formatted} = formatMfaMd(MFA),
{[{reason, badarity} | Md], eFmt:formatBin("fun called with wrong arity of ~w instead of ~w in ~s", [length(Args), Arity, Formatted])};
{[{reason, badarity} | Md], eFmt:formatBin(<<"fun called with wrong arity of ~w instead of ~w in ~s";>>;, [length(Args), Arity, Formatted])};
formatReasonMd({noproc, MFA}) ->
{Md, Formatted} = formatMfaMd(MFA),
{[{reason, noproc} | Md], <<"no such process or port in call to ", Formatted/binary>>};

+ 6
- 6
src/formatter/lgFmtTer.erl 查看文件

@ -145,11 +145,11 @@ outColor(Colors, LgMsg) ->
makeStr(A) when is_atom(A) -> atom_to_binary(A);
makeStr(P) when is_pid(P) -> list_to_binary(pid_to_list(P));
makeStr(B) when is_binary(B) -> B;
makeStr(Other) -> eFmt:formatBin("~p", [Other]).
makeStr(Other) -> eFmt:formatBin(<<"~p";>>;, [Other]).
makeList(A) when is_atom(A) -> atom_to_list(A);
makeList(P) when is_pid(P) -> pid_to_list(P);
makeList(Other) -> binary_to_list(eFmt:formatBin("~p", [Other])).
makeList(Other) -> binary_to_list(eFmt:formatBin(<<"~p";>>;, [Other])).
makeStr(A, W) when is_integer(W) -> makeStr(left, makeList(A), W);
makeStr(A, {Align, W}) when is_integer(W) ->
@ -229,16 +229,16 @@ sevSeverity(?none) -> <<"[o]">>.
mdJoin([], _FieldSep, BinAcc) ->
BinAcc;
mdJoin([{_K, V}], _FieldSep, BinAcc) ->
<<BinAcc/binary, (eFmt:formatBin("~p", [V]))/binary>>;
<<BinAcc/binary, (eFmt:formatBin(<<"~p";>>;, [V]))/binary>>;
mdJoin([{_K, V} | Left], FieldSep, BinAcc) ->
mdJoin(Left, FieldSep, <<BinAcc/binary, (eFmt:formatBin("~p", [V]))/binary, FieldSep/binary>>).
mdJoin(Left, FieldSep, <<BinAcc/binary, (eFmt:formatBin(<<"~p";>>;, [V]))/binary, FieldSep/binary>>).
mdJoin([], _IntSep, _FieldSep, BinAcc) ->
BinAcc;
mdJoin([{K, V}], IntSep, _FieldSep, BinAcc) ->
<<BinAcc/binary, (eFmt:formatBin("~p~s~p", [K, IntSep, V]))/binary>>;
<<BinAcc/binary, (eFmt:formatBin(<<"~p~s~p";>>;, [K, IntSep, V]))/binary>>;
mdJoin([{K, V} | Left], IntSep, FieldSep, BinAcc) ->
mdJoin(Left, FieldSep, <<BinAcc/binary, (eFmt:formatBin("~p~s~p", [K, IntSep, V]))/binary, FieldSep/binary>>).
mdJoin(Left, FieldSep, <<BinAcc/binary, (eFmt:formatBin(<<"~p~s~p";>>;, [K, IntSep, V]))/binary, FieldSep/binary>>).

+ 8
- 8
src/watcher/lgHWatcherSrv.erl 查看文件

@ -36,11 +36,11 @@ init({Sink, Module, Config}) ->
{ok, #state{sink = Sink, module = Module, config = Config}}.
handleCall(_Msg, _State, _From) ->
?ERR("~p call receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p call receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
{reply, ok}.
handleCast(_Msg, _State) ->
?ERR("~p cast receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p cast receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
kpS.
handleInfo({gen_event_EXIT, Module, normal}, #state{module = Module} = State) ->
@ -56,14 +56,14 @@ handleInfo({gen_event_EXIT, Module, {'EXIT', {kill_me, [_KillerHwm, KillerReinst
SinkPid = whereis(Sink),
unlink(SinkPid),
{_, Len} = process_info(SinkPid, message_queue_len),
error_logger:error_msg("Killing sink ~p, current message_queue_len:~p~n", [Sink, Len]),
error_logger:error_msg(<<"Killing sink ~p, current message_queue_len:~p~n";>>;, [Sink, Len]),
exit(SinkPid, kill),
_ = timer:apply_after(KillerReinstallAfter, eLog_app, startHandler, [Sink, Module, Config]),
{stop, normal, State};
handleInfo({gen_event_EXIT, Module, Reason}, #state{module = Module, config = Config, sink = Sink} = State) ->
case ?LgShouldLog(?error) of
true ->
?LgNotify(?error, self(), "eLog event handler ~p exited with reason ~s", [Module, lgErrLoggerH:formatReason(Reason)]),
?LgNotify(?error, self(), <<"eLog event handler ~p exited with reason ~s";>>;, [Module, lgErrLoggerH:formatReason(Reason)]),
installHandler(Module, Config, Sink);
_ ->
ok
@ -82,7 +82,7 @@ handleInfo({'EXIT', _Pid, killed}, #state{module = Module, config = Config, sink
_ = timer:apply_after(Tmr, eLog_app, startHandler, [Sink, Module, Config]),
{stop, normal, State};
handleInfo(_Msg, _State) ->
?ERR("~p info receive unexpect msg ~p ~n ", [?MODULE, _Msg]),
?ERR(<<"~p info receive unexpect msg ~p ~n ";>>;, [?MODULE, _Msg]),
kpS.
terminate(_Reason, _State) ->
@ -105,17 +105,17 @@ installHandler(Module, Config, Sink) ->
end,
case Ret of
ok ->
?INT_LOG(?debug, "eLog installed handler ~p into ~p ~p", [Module, Sink, whereis(Sink)]),
?INT_LOG(?debug, <<"eLog installed handler ~p into ~p ~p";>>;, [Module, Sink, whereis(Sink)]),
%eLog:updateLogevelCfg(Sink),
ok;
{error, {fatal, Reason}} ->
?INT_LOG(?error, "eLog fatally failed to install handler ~p into ~p, NOT retrying: ~p", [Module, Sink, Reason]),
?INT_LOG(?error, <<"eLog fatally failed to install handler ~p into ~p, NOT retrying: ~p";>>;, [Module, Sink, Reason]),
%% tell ourselves to stop
self() ! stop,
ok;
Error ->
%% try to reinstall it later
?INT_LOG(?error, "eLog failed to install handler ~p into ~p, retrying later : ~p", [Module, Sink, Error]),
?INT_LOG(?error, <<"eLog failed to install handler ~p into ~p, retrying later : ~p";>>;, [Module, Sink, Error]),
erlang:send_after(5000, self(), mReinstallHandler),
ok
end.

Loading…
取消
儲存