@@ -102,8 +102,8 @@ defmodule Logger do
102
102
103
103
Furthermore, metadata can be set per process with `Logger.metadata/1`.
104
104
105
- Some metadata, however, is always added automatically by Logger
106
- whenever possible. Those are:
105
+ Some metadata, however, may be added automatically by Logger whenever
106
+ possible. Those are:
107
107
108
108
* `:application` - the current application
109
109
@@ -137,13 +137,13 @@ defmodule Logger do
137
137
There are two special metadata keys, `:module` and `:function`, which
138
138
extract the relevant bits from `:mfa`.
139
139
140
- Note that all metadata is optional and may not always be available.
141
- The `:mfa`, `:file`, `:line`, and similar metadata are automatically
142
- included when using `Logger` macros. `Logger.bare_log/3` does not include
143
- any metadata beyond the `:pid` by default. Other metadata, such as
140
+ The metadata keys above may not always be available. The `:mfa`, `:file`,
141
+ `:line`, and similar metadata are automatically included when using `Logger`
142
+ macros, but not when using `Logger.bare_log/3`. Other metadata, such as
144
143
`:crash_reason`, `:initial_call`, and `:registered_name` are available
145
144
only inside behaviours such as GenServer, Supervisor, and others.
146
145
146
+ It is also possible to pass metadata on a particular Logger invocation.
147
147
For example, you might wish to include a custom `:error_code` metadata in
148
148
your logs:
149
149
@@ -196,8 +196,10 @@ defmodule Logger do
196
196
if `:handle_otp_reports` is true.
197
197
198
198
* `:metadata` - key-value pairs of global primary metadata to be included
199
- in all log messages. Defaults to `[]`. This can be overridden at the process
200
- level with `metadata/1` or each on log call as desired.
199
+ in all log messages. Defaults to `[]`. The default formatter writes to
200
+ standard out and therefore cannot print all metadata. See
201
+ [`Logger.Formatter`'s documentation](Logger.Formatter.html#module-metadata`)
202
+ for more information.
201
203
202
204
For example, to configure `Logger` to redirect all Erlang messages using a
203
205
`config/config.exs` file:
@@ -529,9 +531,8 @@ defmodule Logger do
529
531
with the exception of setting a key to `nil`, which will remove that key
530
532
from the metadata.
531
533
532
- Note not all keys can be set as metadata. The metadata automatically added
533
- by Logger, as declared in the module documentation, will always override
534
- custom one.
534
+ Note some metadata keys are reserved and cannot be overridden. See
535
+ [the module documentation](#module-metadata) for more information.
535
536
"""
536
537
@ spec metadata ( metadata ) :: :ok
537
538
def metadata ( keyword ) do
0 commit comments