@ -35,18 +35,18 @@
raw : : boolean ( )
} ) .
- define ( LOGMSG ( Sink , Level , Pid , Msg ) ,
case ? LgShouldLog ( Sink , Level ) of
- define ( LOGMSG ( Sink , Severity , Pid , Msg ) ,
case ? LgShouldLog ( Sink , Severity ) of
true - >
_ = eLog : log ( Sink , Level , Pid , Msg , [ ] ) ,
eLog : doLogImpl ( Severity , Pid , undefined , undefined , undefined , 0 , [ ] , Msg , [ ] , 0 , Sink , safe ) ,
logged ;
_ - > no_log
end ) .
- define ( LOGFMT ( Sink , Level , Pid , Fmt , Args ) ,
case ? LgShouldLog ( Sink , Level ) of
- define ( LOGFMT ( Sink , Severity , Pid , Fmt , Args ) ,
case ? LgShouldLog ( Sink , Severity ) of
true - >
_ = eLog : log ( Sink , Level , Pid , Fmt , Args ) ,
eLog : doLogImpl ( Severity , Pid , undefined , undefined , undefined , 0 , [ ] , Fmt , Args , 0 , Sink , safe ) ,
logged ;
_ - > no_log
end ) .
@ -76,22 +76,26 @@ handle_call({mSetHighWater, N}, #state{shaper = Shaper} = State) ->
NewShaper = Shaper #lgShaper { hwm = N } ,
{ ok , ok , State #state { shaper = NewShaper } } ;
handle_call ( _ Request , State ) - >
io : format ( " IMY*********************handle_call111 " ) ,
{ ok , unknown_call , State } .
handle_event ( Event , #state { sink = Sink , shaper = Shaper } = State ) - >
io : format ( " IMY**********************111111111 ~p ~n " , [ Event ] ) ,
case lgUtil : checkHwm ( Shaper , Event ) of
{ true , _ Drop , NewShaper } - >
io : format ( " IMY**********************1111111110-0000 ~p ~n " , [ Event ] ) ,
evalGl ( Event , State #state { shaper = NewShaper } ) ;
{ drop , Drop , NewShaper } - >
io : format ( " IMY**********************1111111110-111 ~p ~n " , [ Event ] ) ,
case Drop =< 0 of
true - >
{ ok , State #state { shaper = NewShaper } } ;
_ - >
? LOGFMT ( Sink , warning , self ( ) , " lager_error_logger_h dropped ~p messages in the last second that exceeded the limit of ~p messages/sec " , [ Drop , NewShaper #lgShaper.hwm ] ) ,
? LOGFMT ( Sink , ? warning , self ( ) , " lager_error_logger_h 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 } - >
io : format ( " IMY**********************1111111110-2222 ~p ~n " , [ Event ] ) ,
{ ok , State #state { shaper = NewShaper } }
end .
@ -100,10 +104,11 @@ handle_info({mShaperExpired, ?MODULE}, #state{sink = Sink, shaper = Shaper} = St
0 - >
ignore ;
Dropped - >
? LOGFMT ( Sink , warning , self ( ) , " lager_error_logger_h dropped ~p messages in the last second that exceeded the limit of ~p messages/sec " , [ Dropped , Shaper #lgShaper.hwm ] )
? LOGFMT ( Sink , ? warning , self ( ) , " lager_error_logger_h 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 ) - >
io : format ( " IMY*********************handle_info111 " ) ,
{ ok , State } .
terminate ( _ Reason , _ State ) - >
@ -130,9 +135,11 @@ configSink() ->
end .
evalGl ( Event , #state { groupleader_strategy = GlStrategy0 } = State ) - >
io : format ( " IMY*********************evalGl000 ~p ~n " , [ Event ] ) ,
GL = element ( 2 , Event ) ,
case is_pid ( GL ) andalso node ( GL ) =/= node ( ) of
true - >
io : format ( " IMY*********************evalGl111 ~p ~n " , [ Event ] ) ,
case GlStrategy0 of
ignore - >
gen_event : notify ( { error_logger , node ( GL ) } , Event ) ,
@ -144,6 +151,7 @@ evalGl(Event, #state{groupleader_strategy = GlStrategy0} = State) ->
logEvent ( Event , State )
end ;
_ - >
io : format ( " IMY*********************evalG2222 ~p ~n " , [ Event ] ) ,
logEvent ( Event , State )
end .
@ -170,7 +178,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 } =
@ -187,7 +195,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
@ -210,27 +218,27 @@ 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 ) ,
case Args of
[ Module , Function , Arity , _ Request , _ State ] - >
% % we only get the 5 - element list when its a non - exported function
? LOGFMT ( Sink , error , Pid ,
? LOGFMT ( Sink , ? error , Pid ,
" 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 ] ,
? LOGFMT ( Sink , ? error , [ { pid , Pid } | Md ] ,
" Cowboy handler ~p terminated in ~p : ~p / ~p with reason: ~s " , [ Module , Module , Function , Arity , Formatted ] )
end ;
" Ranch listener " ++ _ - >
@ -240,19 +248,19 @@ logEvent(Event, #state{sink = Sink, raw = FormatRaw} = State) ->
% % Error logged by cowboy , which starts as ranch error
[ Ref , ConnectionPid , StreamID , RequestPid , Reason , StackTrace ] - >
{ Md , Formatted } = formatReasonMd ( { Reason , StackTrace } ) ,
? LOGFMT ( Sink , error , [ { pid , RequestPid } | Md ] ,
? 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 ] ) ;
[ 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
@ -267,37 +275,40 @@ 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 )
end ;
_ - >
? CRASH_LOG ( Event ) ,
? LOGFMT ( Sink , error , Pid , Fmt , Args )
? LOGFMT ( Sink , ? error , Pid , Fmt , Args )
end ;
{ error_report , _ GL , { Pid , std_error , D } } - >
? CRASH_LOG ( Event ) ,
? LOGMSG ( Sink , error , Pid , printSillyList ( D ) ) ;
? LOGMSG ( Sink , ? error , Pid , printSillyList ( D ) ) ;
{ error_report , _ GL , { Pid , supervisor_report , D } } - >
? CRASH_LOG ( Event ) ,
case lists : sort ( D ) of
[ { errorContext , Ctx } , { offender , Off } , { reason , Reason } , { supervisor , Name } ] - >
Offender = formatOffender ( Off ) ,
{ Md , Formatted } = formatReasonMd ( Reason ) ,
? LOGFMT ( Sink , error , [ { pid , Pid } | Md ] ,
? LOGFMT ( Sink , ? error , [ { pid , Pid } | Md ] ,
" 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 > > )
? LOGMSG ( Sink , ? error , Pid , < < " SUPERVISOR REPORT " , ( printSillyList ( D ) ) / binary > > )
end ;
{ 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 ) ;
{ warning_msg , _ GL , { Pid , Fmt , Args } } - >
? LOGFMT ( Sink , warning , Pid , Fmt , Args ) ;
? LOGFMT ( Sink , ? warning , Pid , Fmt , Args ) ;
{ warning_report , _ GL , { Pid , std_warning , Report } } - >
? LOGMSG ( Sink , warning , Pid , printSillyList ( Report ) ) ;
? LOGMSG ( Sink , ? warning , Pid , printSillyList ( Report ) ) ;
{ info_msg , _ GL , { Pid , Fmt , Args } } - >
? LOGFMT ( Sink , info , Pid , Fmt , Args ) ;
? LOGFMT ( Sink , ? info , Pid , Fmt , Args ) ;
{ info_report , _ GL , { Pid , std_info , D } } when is_list ( D ) - >
Details = lists : sort ( D ) ,
case Details of
@ -307,13 +318,13 @@ 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 ) )
? LOGMSG ( Sink , ? info , Pid , printSillyList ( D ) )
end ;
{ info_report , _ GL , { Pid , std_info , D } } - >
? LOGFMT ( Sink , info , Pid , " ~w " , [ D ] ) ;
? LOGFMT ( Sink , ? info , Pid , " ~w " , [ D ] ) ;
{ info_report , _ GL , { P , progress , D } } - >
Details = lists : sort ( D ) ,
case Details of
@ -322,7 +333,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
@ -331,14 +342,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 > > )
? 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 - >