erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.39k stars 2.95k forks source link

ERL-1197: How does one create a logger handler with overload protection? #3914

Open OTP-Maintainer opened 4 years ago

OTP-Maintainer commented 4 years ago

Original reporter: bucko909 Affected version: Not Specified Component: Not Specified Migrated from: https://bugs.erlang.org/browse/ERL-1197


I've been trying to make a new handler to submit log entries to Sentry (a la raven) using the new {{logger}} API. I'm struck by a few things:
 * The new features such as overload protection rely on implementing callbacks for an undocumented behaviour ({{logger_h_common}}).
 * Logger specifies certain helpers for formatters, but the handler is responsible for calling them.
 * The formatter isn't actually used at all for OTP messages, even in the default loggers.
 * Using {{error_logger}} doesn't get the overload protection features, as it doesn't actually use {{logger_h_common}}.

I think I've just about cobbled together something that works, but I think it'd be great if this module could "come out of the woodwork" and be a real tool to aid developers in development of logger handlers – especially as I'm going to be using an undocumented API!

(Overload protection is necessary in this case because it's going to need to do HTTP requests for each message to a server than may be poorly. I'm reluctant to use {{httpc}} because it doesn't document its {{\{sync, true\}}} behaviour – I don't want to bother any other users of that module, not allow unbounded parallelism!)
garazdawi commented 2 years ago

Related to #4050