Skip to content

Commit 90f83e1

Browse files
author
José Valim
committed
Improve docs for Logger
1 parent 562af52 commit 90f83e1

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lib/logger/lib/logger.ex

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ defmodule Logger do
120120
The initial backends are loaded via the `:backends` configuration,
121121
which must be set before the logger application is started. However,
122122
backends can be added or removed dynamically via the `add_backend/2`,
123-
`remove_backend/1` and `configure_backend/2` functions. Note though
124-
that dynamically added backends are not restarded in case of crashes.
123+
`remove_backend/1` and `configure_backend/2` functions, although such
124+
backends are not persisted (i.e. if the Logger supervision tree crashes,
125+
they are not re-added).
125126
126127
### Console backend
127128
@@ -154,15 +155,15 @@ defmodule Logger do
154155
writing a new backend is a matter of creating an event
155156
handler, as described in the `GenEvent` module.
156157
157-
From now on, we will be using event handler to refer to
158-
your custom backend, as we head into implementation details.
158+
From now on, we will be using the term "event handler" to refer
159+
to your custom backend, as we head into implementation details.
159160
160-
The `add_backend/1` function is used to start a new
161-
backend, which installs the given event handler to the
162-
Logger event manager. This event handler is automatically
163-
supervised by Logger.
161+
Once Logger starts, it installs all event handlers under
162+
the `:backends` configuration into Logger event manager.
163+
The event manager and all added event handlers are
164+
automatically supervised by Logger.
164165
165-
Once added, the handler should be able to handle events
166+
Once initialized, the handler should be able to handle events
166167
in the following format:
167168
168169
{level, group_leader,
@@ -178,15 +179,15 @@ defmodule Logger do
178179
the group leader is in a different node than the one
179180
the handler is installed.
180181
181-
Furthermore, backends can be configured via the `configure_backend/2`
182-
function which requires event handlers to handle calls of
183-
the following format:
182+
Furthermore, backends can be configured via the
183+
`configure_backend/2` function which requires event handlers
184+
to handle calls of the following format:
184185
185186
{:configure, options}
186187
187188
where options is a keyword list. The result of the call is
188-
the result returned by `configure_backend/2`. You may simply
189-
return `:ok` if you don't perform any kind of validation.
189+
the result returned by `configure_backend/2`. The recommended
190+
return value for successful configuration is `:ok`.
190191
191192
It is recommended that backends support at least the following
192193
configuration values:

0 commit comments

Comments
 (0)