Skip to content

Commit

Permalink
Add location info to logger printouts
Browse files Browse the repository at this point in the history
  • Loading branch information
dgud committed Nov 12, 2024
1 parent 7d8ff75 commit b643f35
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/ssl/src/ssl_logger.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
log(Level, LogLevel, ReportMap, Meta) ->
case logger:compare_levels(LogLevel, Level) of
lt ->
logger:log(Level, ReportMap, Meta#{depth => ?DEPTH,
report_cb => fun ?MODULE:format/1});
logger:log(Level, maps:merge(ReportMap, Meta),
Meta#{depth => ?DEPTH, report_cb => fun ?MODULE:format/1});
eq ->
logger:log(Level, ReportMap, Meta#{depth => ?DEPTH,
report_cb => fun ?MODULE:format/1});
logger:log(Level, maps:merge(ReportMap, Meta),
Meta#{depth => ?DEPTH, report_cb => fun ?MODULE:format/1});
_ ->
ok
end.
Expand Down Expand Up @@ -99,11 +99,15 @@ format(#{alert := Alert, alerter := ignored} = Report) ->
%% Happens in DTLS
{Fmt, Args} = ssl_alert:own_alert_format(ProtocolName, Role, StateName, Alert),
{"~s " ++ Fmt, ["Ignored alert to mitigate DoS attacks", Args]};
format(#{description := Desc, reason := Reason, file := Mod, line := Line}) ->
{"~12s ~p~n"
"~12s ~p~n"
"~12s ~s:~w~n",
["Description:", Desc, "Reason:", Reason, "Location:", Mod, Line]
};
format(#{description := Desc, reason := Reason}) ->
{"~12s ~p"
"~n"
"~12s ~p"
"~n",
{"~12s ~p~n"
"~12s ~p~n",
["Description:", Desc, "Reason:", Reason]
}.

Expand Down

0 comments on commit b643f35

Please sign in to comment.