From 58fd5b778e32eee247aec76a200976016ecfa791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Z=C3=B6ger?= Date: Thu, 10 Dec 2020 17:16:43 +0100 Subject: [PATCH] feat: Support for structured warning messages to Sentry (#10) * feat: Support for structured warning messages to Sentry * feat: Adds possibility to override level in ?exception macro --- src/raven_error_logger.erl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/raven_error_logger.erl b/src/raven_error_logger.erl index 2ed12bf..1830fe7 100644 --- a/src/raven_error_logger.erl +++ b/src/raven_error_logger.erl @@ -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, [