Skip to content

Commit

Permalink
feat: Support for structured warning messages to Sentry (#10)
Browse files Browse the repository at this point in the history
* feat: Support for structured warning messages to Sentry
* feat: Adds possibility to override level in ?exception macro
  • Loading branch information
zigge-zagge authored Dec 10, 2020
1 parent 0e39934 commit 58fd5b7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/raven_error_logger.erl
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,26 @@ parse_message(Level, Pid, "Error: ~p" ++ _ = Format, [{failed, Reason, Extras} |
]}
| User
]};
parse_message(Level, Pid, "Warning: ~p~n" ++ Format, [{extras, Extras} | Data])
when is_list(Extras) ->
{User, ExtrasWithoutUser} = extract_user(Extras),
{format(Format, Data), [
{level, Level},
{extra, [
{pid, Pid} |
[ {Key, Value} || {Key, Value} <- ExtrasWithoutUser, is_atom(Key) ]
]}
| User
]};
parse_message(Level, Pid, "Exception: ~p\n"
"Extras: ~p" = Format,
[{{Class, Reason}, [{_, _, _, _} | _] = Stacktrace}, Extras])
when Class =:= exit; Class =:= error; Class =:= throw ->
{User, ExtrasWithoutUser} = extract_user(Extras),
ExtrasLevel = proplists:get_value(level, Extras, false),
TheLevel = ExtrasLevel orelse Level,
{format(Format, [{Class, Reason}, Extras]), [
{level, Level},
{level, TheLevel},
{exception, {Class, Reason}},
{stacktrace, Stacktrace},
{extra, [
Expand Down

0 comments on commit 58fd5b7

Please sign in to comment.