Skip to content

Commit 5a57c26

Browse files
Add Logger.add_handlers/1 (#12412)
Co-authored-by: José Valim <[email protected]>
1 parent 10e14ea commit 5a57c26

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lib/logger/lib/logger.ex

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,11 @@ defmodule Logger do
319319
320320
Each handler has the shape `{:handler, name, handler_module, config_map}`.
321321
Once defined, a handler can be explicitly attached in your
322-
`c:Application.start/2` callback:
322+
`c:Application.start/2` callback with `add_handlers/1`:
323323
324-
:logger.add_handlers(:my_app)
324+
Logger.add_handlers(:my_app)
325325
326-
You can also developer your own handlers. Erlang handlers run in the same
326+
You can also develop your own handlers. Handlers run in the same
327327
process as the process logging the message/event. This gives developers
328328
flexibility but they should avoid performing any long running action in
329329
such handlers, as it may slow down the action being executed considerably.
@@ -725,6 +725,20 @@ defmodule Logger do
725725
:ok
726726
end
727727

728+
@doc """
729+
Adds the handlers configured in the `:logger` application parameter
730+
of the given `app`.
731+
732+
This is used to register new handlers into the logging system.
733+
See [the module documentation](#module-erlang-otp-handlers) for
734+
more information.
735+
"""
736+
@doc since: "1.15.0"
737+
@spec add_handlers(atom()) :: :ok | {:error, term}
738+
def add_handlers(app) when is_atom(app) do
739+
:logger.add_handlers(app)
740+
end
741+
728742
@doc """
729743
Adds a new backend.
730744
"""

0 commit comments

Comments
 (0)