-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logger backend #829
Logger backend #829
Conversation
Previously, Appsignal.Logger only exposed the named functions (like debug/3). Since we need the log/4 function to provide a backend, this patch eposes it.
Appsignal.Logger.Backend is attached to Elixir's logger to send logs to AppSignal. Use Logger.add_backend/1 to set it up: Logger.add_backend({Appsignal.Logger.Backend, "phoenix"}) The second argument in the tuple is the log group name, which could be "phoenix" for a Phoenix application, for example.
> Add Logger backend to redirect Elixir logs to AppSignal.
It should also be possible to configure it in the application environment, like in config :logger, :backends, [{Appsignal.Logger.Backend, "phoenix"}] I'm asking specifically about this because I get the impression that this would be the preferred usage pattern, and I think we should prioritise this in documentation over |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens in a scenario where AppSignal is not active? Say, if this backend is configured in the general config, but AppSignal is only active in certain environments. I think the call to Appsignal.Nif
might break, but I don't really know enough about the Nif setup to be sure.
Co-authored-by: Noemi <45180344+unflxw@users.noreply.github.com>
Yes, and agreed. |
This comment has been minimized.
This comment has been minimized.
If AppSignal is not active, the log/2 function is a noop, so that’s accounted for. :) |
Instead of taking a string as the log group, take a keyword list with a single key, for possible extension later.
c48cc0b
to
0035923
Compare
This comment has been minimized.
This comment has been minimized.
Deprecated, but still used in older versions of Elixir, warnings named :warn previously broke the logger. This patch accepts them as warnings.
Although this shouldn't happen, not finding a severity in the list caused Appsignal.Logger.Backend to crash. This patch adds a rescue clause to turn everything that doesn't match the list to a severity of 3 (info).
This comment has been minimized.
This comment has been minimized.
1 similar comment
While performing the daily checks some issues were found with this Pull Request.
|
With the new logger backend, users can redirect their logs to AppSignal by attaching the backend in their application.ex files:
Closes #800.