@@ -14,11 +14,11 @@ defmodule Logger do
14
14
* Formats and truncates messages on the client
15
15
to avoid clogging logger backends.
16
16
17
- * Alternates between sync and async modes to keep
18
- it performant when required but also apply back-
19
- pressure when under stress.
17
+ * Alternates between sync and async modes to remain
18
+ performant when required but also apply back-pressure
19
+ when under stress.
20
20
21
- * Wraps OTP's error_logger to avoid it from
21
+ * Wraps OTP's ` error_logger` to prevent it from
22
22
overflowing.
23
23
24
24
## Levels
@@ -32,18 +32,18 @@ defmodule Logger do
32
32
33
33
## Configuration
34
34
35
- Logger supports a wide range of configuration .
35
+ Logger supports a wide range of configurations .
36
36
37
37
This configuration is split in three categories:
38
38
39
39
* Application configuration - must be set before the logger
40
40
application is started
41
41
42
42
* Runtime configuration - can be set before the logger
43
- application is started but changed during runtime
43
+ application is started, but may be changed during runtime
44
44
45
45
* Error logger configuration - configuration for the
46
- wrapper around OTP's error_logger
46
+ wrapper around OTP's ` error_logger`
47
47
48
48
### Application configuration
49
49
@@ -55,38 +55,38 @@ defmodule Logger do
55
55
56
56
* `:compile_time_purge_level` - purge all calls that have log level
57
57
lower than the configured value at compilation time. This means the
58
- Logger call will be completely removed at compile time, occuring
59
- no overhead at runtime. By default, defaults to `:debug` and only
58
+ Logger call will be completely removed at compile time, accruing
59
+ no overhead at runtime. Defaults to `:debug` and only
60
60
applies to the `Logger.debug`, `Logger.info`, etc style of calls.
61
61
62
62
### Runtime Configuration
63
63
64
- All configuration below can be set via the config files but also
64
+ All configuration below can be set via config files but also
65
65
changed dynamically during runtime via `Logger.configure/1`.
66
66
67
67
* `:level` - the logging level. Attempting to log any message
68
68
with severity less than the configured level will simply
69
69
cause the message to be ignored. Keep in mind that each backend
70
- may have its specific level too.
70
+ may have its specific level, too.
71
71
72
- * `:utc_log` - when true, uses UTC in logs. By default it uses
73
- local time (i.e. it defaults to false).
72
+ * `:utc_log` - when ` true` , uses UTC in logs. By default it uses
73
+ local time (i.e. it defaults to ` false` ).
74
74
75
75
* `:truncate` - the maximum message size to be logged. Defaults
76
76
to 8192 bytes. Note this configuration is approximate. Truncated
77
- messages will have " (truncated)" at the end.
77
+ messages will have ` " (truncated)"` at the end.
78
78
79
79
* `:sync_threshold` - if the logger manager has more than
80
- `sync_threshold` messages in its queue, logger will change
80
+ `sync_threshold` messages in its queue, Logger will change
81
81
to sync mode, to apply back-pressure to the clients.
82
- Logger will return to sync mode once the number of messages
83
- in the queue reduce to `sync_threshold * 0.75` messages.
82
+ Logger will return to async mode once the number of messages
83
+ in the queue is reduced to `sync_threshold * 0.75` messages.
84
84
Defaults to 20 messages.
85
85
86
86
### Error logger configuration
87
87
88
88
The following configuration applies to the Logger wrapper around
89
- Erlang's error_logger. All the configurations below must be set
89
+ Erlang's ` error_logger` . All the configurations below must be set
90
90
before the logger application starts.
91
91
92
92
* `:handle_otp_reports` - redirects OTP reports to Logger so
@@ -102,11 +102,11 @@ defmodule Logger do
102
102
reached, triggers the error logger to discard messages. This
103
103
value must be a positive number that represents the maximum
104
104
number of messages accepted per second. Once above this
105
- threshold, the error_logger enters in discard mode for the
106
- remaining of that second. Defaults to 500 messages.
105
+ threshold, the ` error_logger` enters discard mode for the
106
+ remainder of that second. Defaults to 500 messages.
107
107
108
108
Furthermore, Logger allows messages sent by Erlang's `error_logger`
109
- to be translated into an Elixir format via translators. Translator
109
+ to be translated into an Elixir format via translators. Translators
110
110
can be dynamically added at any time with the `add_translator/1`
111
111
and `remove_translator/1` APIs. Check `Logger.Translator` for more
112
112
information.
@@ -135,11 +135,11 @@ defmodule Logger do
135
135
following options:
136
136
137
137
* `:level` - the level to be logged by this backend.
138
- Note though messages are first filtered by the general
138
+ Note that messages are first filtered by the general
139
139
`:level` configuration in `:logger`
140
140
141
141
* `:format` - the format message used to print logs.
142
- Defaults to: "$time $metadata[$level] $levelpad$message\n"
142
+ Defaults to: ` "$time $metadata[$level] $levelpad$message\n"`
143
143
144
144
* `:metadata` - the metadata to be printed by `$metadata`.
145
145
Defaults to an empty list (no metadata)
@@ -161,7 +161,7 @@ defmodule Logger do
161
161
162
162
See the `IO.ANSI` module for a list of colors and attributes.
163
163
164
- Here is an example on how to configure the `:console` in a
164
+ Here is an example of how to configure the `:console` backend in a
165
165
`config/config.exs` file:
166
166
167
167
config :logger, :console,
@@ -181,11 +181,11 @@ defmodule Logger do
181
181
to your custom backend, as we head into implementation details.
182
182
183
183
Once Logger starts, it installs all event handlers under
184
- the `:backends` configuration into Logger event manager.
184
+ the `:backends` configuration into the Logger event manager.
185
185
The event manager and all added event handlers are
186
186
automatically supervised by Logger.
187
187
188
- Once initialized, the handler should be able to handle events
188
+ Once initialized, the handler should be designed to handle events
189
189
in the following format:
190
190
191
191
{level, group_leader,
@@ -214,9 +214,9 @@ defmodule Logger do
214
214
It is recommended that backends support at least the following
215
215
configuration values:
216
216
217
- * level - the logging level for that backend
218
- * format - the logging format for that backend
219
- * metadata - the metadata to include the backend
217
+ * ` level` - the logging level for that backend
218
+ * ` format` - the logging format for that backend
219
+ * ` metadata` - the metadata to include the backend
220
220
221
221
Check the implementation for `Logger.Backends.Console` for
222
222
examples on how to handle the recommendations in this section
@@ -317,7 +317,7 @@ defmodule Logger do
317
317
@ doc """
318
318
Compare log levels.
319
319
320
- Receives to log levels and compares the `left`
320
+ Receives two log levels and compares the `left`
321
321
against `right` and returns `:lt`, `:eq` or `:gt`.
322
322
"""
323
323
@ spec compare_levels ( level , level ) :: :lt | :eq | :gt
@@ -393,7 +393,7 @@ defmodule Logger do
393
393
@ doc """
394
394
Logs a message.
395
395
396
- Developers should rather use the macros `Logger.debug/2`,
396
+ Developers should use the macros `Logger.debug/2`,
397
397
`Logger.warn/2`, `Logger.info/2` or `Logger.error/2` instead
398
398
of this function as they automatically include caller metadata
399
399
and can eliminate the Logger call altogether at compile time if
@@ -422,7 +422,7 @@ defmodule Logger do
422
422
423
423
## Examples
424
424
425
- Logger.warn "knob turned too much to the right"
425
+ Logger.warn "knob turned too far to the right"
426
426
Logger.warn fn -> "expensive to calculate warning" end
427
427
428
428
"""
0 commit comments