Parcourir la source

ft: 优化

master
SisMaker il y a 5 mois
Parent
révision
c3c094390c
4 fichiers modifiés avec 6 ajouts et 10 suppressions
  1. +1
    -2
      include/lgDef.hrl
  2. +2
    -4
      src/backend/lgBkdFile.erl
  3. +1
    -2
      src/eLog.erl
  4. +2
    -2
      src/formatter/lgFmtTer.erl

+ 1
- 2
include/lgDef.hrl Voir le fichier

@ -103,7 +103,6 @@
, function :: atom()
, line :: integer()
, metadata :: [tuple()]
, datetime :: binary()
, timestamp :: non_neg_integer()
, message :: list()
, destinations :: list()
@ -124,7 +123,7 @@
-define(LgShouldLog(Level), ?eLogCfg:get(?LgDefSink) band Level =/= 0).
-define(LgNotify(Level, Pid, Format, Args),
gen_emm:info_notify(?LgDefSink, {mWriteLog, #lgMsg{severity = Level, pid = Pid, node = node(), module = ?MODULE, function = ?FUNCTION_NAME, line = ?LINE, metadata = [], datetime = lgUtil:msToBinStr(), timestamp = lgTime:nowMs(), message = eFmt:format(Format, Args), destinations = []}})).
gen_emm:info_notify(?LgDefSink, {mWriteLog, #lgMsg{severity = Level, pid = Pid, node = node(), module = ?MODULE, function = ?FUNCTION_NAME, line = ?LINE, metadata = [], timestamp = lgTime:nowMs(), message = eFmt:format(Format, Args), destinations = []}})).
%%使
-define(INT_LOG(Level, Format, Args),

+ 2
- 4
src/backend/lgBkdFile.erl Voir le fichier

@ -138,8 +138,7 @@ handleEvent({mWriteLog, Message}, #state{fBName = _FBName, level = Level, shaper
_ ->
ReportStr = eFmt:format(<<"lgBkdFile dropped ~p messages in the last second that exceeded the limit of ~p messages/sec">>, [Drop, NewShaper#lgShaper.hwm]),
NowMs = lgTime:nowMs(),
NowStr = lgUtil:msToBinStr(NowMs),
ReportMsg = #lgMsg{severity = ?llvWarning, pid = self(), node = node(), module = ?MODULE, function = ?FUNCTION_NAME, line = ?LINE, metadata = [], datetime = NowStr, timestamp = NowMs, message = ReportStr, destinations = []},
ReportMsg = #lgMsg{severity = ?llvWarning, pid = self(), node = node(), module = ?MODULE, function = ?FUNCTION_NAME, line = ?LINE, metadata = [], timestamp = NowMs, message = ReportStr, destinations = []},
writeLog(State, NowMs, ?llvWarning, FmtTer:format(ReportMsg, FmtCfg))
end,
{noreply, writeLog(TemState#state{shaper = NewShaper}, Timestamp, Severity, FmtTer:format(Message, FmtCfg))};
@ -166,8 +165,7 @@ handleInfo({mShaperExpired, FBName}, #state{shaper = Shaper, fBName = FBName, fm
Dropped ->
ReportStr = eFmt:format(<<"lgBkdFile dropped ~p messages in the last second that exceeded the limit of ~p messages/sec">>, [Dropped, Shaper#lgShaper.hwm]),
NowMs = lgTime:nowMs(),
NowStr = lgUtil:msToBinStr(NowMs),
ReportMsg = #lgMsg{severity = ?llvWarning, pid = self(), node = node(), module = ?MODULE, function = ?FUNCTION_NAME, line = ?LINE, metadata = [], datetime = NowStr, timestamp = NowMs, message = ReportStr, destinations = []},
ReportMsg = #lgMsg{severity = ?llvWarning, pid = self(), node = node(), module = ?MODULE, function = ?FUNCTION_NAME, line = ?LINE, metadata = [], timestamp = NowMs, message = ReportStr, destinations = []},
writeLog(State, NowMs, ?llvWarning, FmtTer:format(ReportMsg, FmtCfg))
end,
{noreply, State#state{shaper = Shaper#lgShaper{dropped = 0}}};

+ 1
- 2
src/eLog.erl Voir le fichier

@ -85,8 +85,7 @@ doLogImpl(Severity, Pid, Node, Module, Function, Line, Metadata, Format, Args, S
MsgStr = ?lgCASE(Args =/= [] andalso Args =/= undefined, ?lgCASE(Safety == safe, safeFormat(Format, Args, [{charsLimit, Size}]), unsafeFormat(Format, Args)), Format),
NowMs = lgTime:nowMs(),
NowStr = lgUtil:msToBinStr(NowMs),
LgMsg = #lgMsg{severity = Severity, pid = Pid, node = Node, module = Module, function = Function, line = Line, metadata = Metadata, datetime = NowStr, timestamp = NowMs, message = MsgStr, destinations = Destinations},
LgMsg = #lgMsg{severity = Severity, pid = Pid, node = Node, module = Module, function = Function, line = Line, metadata = Metadata, timestamp = NowMs, message = MsgStr, destinations = Destinations},
case lgConfig:ptGet({Sink, async}, false) of
true ->

+ 2
- 2
src/formatter/lgFmtTer.erl Voir le fichier

@ -70,7 +70,7 @@ fmtCfg(MetaWhitelist) ->
-spec output(term(), lgMsg()) -> iolist().
output(message, LgMsg) -> LgMsg#lgMsg.message;
output(datetime, LgMsg) -> LgMsg#lgMsg.datetime;
output(datetime, LgMsg) -> lgUtil:msToBinStr(LgMsg#lgMsg.timestamp);
output(pid, LgMsg) -> pid_to_list(LgMsg#lgMsg.pid);
output(node, LgMsg) -> atom_to_binary(LgMsg#lgMsg.node, utf8);
output(module, LgMsg) -> atom_to_binary(LgMsg#lgMsg.module, utf8);
@ -111,7 +111,7 @@ output({Prop, Present, Absent, Width}, LgMsg) when is_atom(Prop) ->
output(Other, _) -> makeStr(Other).
output(message, LgMsg, _Width) -> LgMsg#lgMsg.message;
output(datetime, LgMsg, _Width) -> LgMsg#lgMsg.datetime;
output(datetime, LgMsg, _Width) -> lgUtil:msToBinStr(LgMsg#lgMsg.timestamp);
output(pid, LgMsg, _Width) -> pid_to_list(LgMsg#lgMsg.pid);
output(node, LgMsg, _Width) -> atom_to_binary(LgMsg#lgMsg.node, utf8);
output(module, LgMsg, _Width) -> atom_to_binary(LgMsg#lgMsg.module, utf8);

Chargement…
Annuler
Enregistrer