aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/doc/src/logger.xml
blob: 2beefd12400637141dcd8947978ec42c543fc5bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>2017</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.

    </legalnotice>

    <title>logger</title>
    <prepared></prepared>
    <responsible></responsible>
    <docno></docno>
    <approved></approved>
    <checked></checked>
    <date></date>
    <rev>A</rev>
    <file>logger.xml</file>
  </header>
  <module>logger</module>
  <modulesummary>API module for the logger application.</modulesummary>

  <description>

  </description>

  <datatypes>
    <datatype>
      <name name="level"/>
      <desc>
	<p>The severity level for the message to be logged.</p>
      </desc>
    </datatype>
    <datatype>
      <name name="log"/>
      <desc>
	<p></p>
      </desc>
    </datatype>
    <datatype>
      <name name="report"/>
      <desc>
	<p></p>
      </desc>
    </datatype>
    <datatype>
      <name name="msg_fun"/>
      <desc>
	<p></p>
      </desc>
    </datatype>
    <datatype>
      <name name="metadata"/>
      <desc>
	<p>Metadata associated with the message to be logged.</p>
      </desc>
    </datatype>
    <datatype>
      <name name="config"/>
      <desc>
	<p></p>
      </desc>
    </datatype>
    <datatype>
      <name name="handler_id"/>
      <desc>
	<p></p>
      </desc>
    </datatype>
    <datatype>
      <name name="filter_id"/>
      <desc>
	<p></p>
      </desc>
    </datatype>
    <datatype>
      <name name="filter"/>
      <desc>
	<p></p>
      </desc>
    </datatype>
    <datatype>
      <name name="filter_return"/>
      <desc>
	<p></p>
      </desc>
    </datatype>
  </datatypes>

  <section>
    <title>Macros</title>
    <p>The following macros are defined:</p>

    <list>
      <item><c>?LOG_EMERGENCY(StringOrReport[,Metadata])</c></item>
      <item><c>?LOG_EMERGENCY(FunOrFormat,Args[,Metadata])</c></item>
      <item><c>?LOG_ALERT(StringOrReport[,Metadata])</c></item>
      <item><c>?LOG_ALERT(FunOrFormat,Args[,Metadata])</c></item>
      <item><c>?LOG_CRITICAL(StringOrReport[,Metadata])</c></item>
      <item><c>?LOG_CRITICAL(FunOrFormat,Args[,Metadata])</c></item>
      <item><c>?LOG_ERROR(StringOrReport[,Metadata])</c></item>
      <item><c>?LOG_ERROR(FunOrFormat,Args[,Metadata])</c></item>
      <item><c>?LOG_WARNING(StringOrReport[,Metadata])</c></item>
      <item><c>?LOG_WARNING(FunOrFormat,Args[,Metadata])</c></item>
      <item><c>?LOG_NOTICE(StringOrReport[,Metadata])</c></item>
      <item><c>?LOG_NOTICE(FunOrFormat,Args[,Metadata])</c></item>
      <item><c>?LOG_INFO(StringOrReport[,Metadata])</c></item>
      <item><c>?LOG_INFO(FunOrFormat,Args[,Metadata])</c></item>
      <item><c>?LOG_DEBUG(StringOrReport[,Metadata])</c></item>
      <item><c>?LOG_DEBUG(FunOrFormat,Args[,Metadata])</c></item>
    </list>

    <p>All macros expand to a call to logger, where <c>Level</c> is
      taken from the macro name, and the following metadata is added,
      or merged with the given <c>Metadata</c>:</p>

    <code>
#{mfa=>{?MODULE,?FUNCTION_NAME,?FUNCTION_ARITY},
  file=>?FILE,
  line=>?LINE}
    </code>

    <p>The call is wrapped in a case statement and will be evaluated
      only if <c>Level</c> is equal to or below the configured log
      level.</p>
  </section>

  <funcs>
    <func>
      <name>emergency(StringOrReport[,Metadata])</name>
      <name>emergency(Format,Args[,Metadata])</name>
      <name>emergency(Fun,FunArgs[,Metadata])</name>
      <fsummary>Logs the given message as level <c>emergency</c>.</fsummary>
      <desc>
        <p>Equivalent to
	<seealso marker="#log-2"><c>log(emergency,...)</c></seealso>.</p>
      </desc>
    </func>

    <func>
      <name>alert(StringOrReport[,Metadata])</name>
      <name>alert(Format,Args[,Metadata])</name>
      <name>alert(Fun,FunArgs[,Metadata])</name>
      <fsummary>Logs the given message as level <c>alert</c>.</fsummary>
      <desc>
        <p>Equivalent to
	<seealso marker="#log-2"><c>log(alert,...)</c></seealso>.</p>
      </desc>
    </func>

    <func>
      <name>critical(StringOrReport[,Metadata])</name>
      <name>critical(Format,Args[,Metadata])</name>
      <name>critical(Fun,FunArgs[,Metadata])</name>
      <fsummary>Logs the given message as level <c>critical</c>.</fsummary>
      <desc>
        <p>Equivalent to
	<seealso marker="#log-2"><c>log(critical,...)</c></seealso>.</p>
      </desc>
    </func>

    <func>
      <name>error(StringOrReport[,Metadata])</name>
      <name>error(Format,Args[,Metadata])</name>
      <name>error(Fun,FunArgs[,Metadata])</name>
      <fsummary>Logs the given message as level <c>error</c>.</fsummary>
      <desc>
        <p>Equivalent to
	<seealso marker="#log-2"><c>log(error,...)</c></seealso>.</p>
      </desc>
    </func>

    <func>
      <name>warning(StringOrReport[,Metadata])</name>
      <name>warning(Format,Args[,Metadata])</name>
      <name>warning(Fun,FunArgs[,Metadata])</name>
      <fsummary>Logs the given message as level <c>warning</c>.</fsummary>
      <desc>
        <p>Equivalent to
	<seealso marker="#log-2"><c>log(warning,...)</c></seealso>.</p>
      </desc>
    </func>

    <func>
      <name>notice(StringOrReport[,Metadata])</name>
      <name>notice(Format,Args[,Metadata])</name>
      <name>notice(Fun,FunArgs[,Metadata])</name>
      <fsummary>Logs the given message as level <c>notice</c>.</fsummary>
      <desc>
        <p>Equivalent to
	<seealso marker="#log-2"><c>log(notice,...)</c></seealso>.</p>
      </desc>
    </func>

    <func>
      <name>info(StringOrReport[,Metadata])</name>
      <name>info(Format,Args[,Metadata])</name>
      <name>info(Fun,FunArgs[,Metadata])</name>
      <fsummary>Logs the given message as level <c>info</c>.</fsummary>
      <desc>
        <p>Equivalent to
	<seealso marker="#log-2"><c>log(info,...)</c></seealso>.</p>
      </desc>
    </func>

    <func>
      <name>debug(StringOrReport[,Metadata])</name>
      <name>debug(Format,Args[,Metadata])</name>
      <name>debug(Fun,FunArgs[,Metadata])</name>
      <fsummary>Logs the given message as level <c>debug</c>.</fsummary>
      <desc>
        <p>Equivalent to
	<seealso marker="#log-2"><c>log(debug,...)</c></seealso>.</p>
      </desc>
    </func>

    <func>
      <name name="log" arity="2"/>
      <name name="log" arity="3" clause_i="1"/>
      <name name="log" arity="3" clause_i="2"/>
      <name name="log" arity="3" clause_i="3"/>
      <name name="log" arity="4" clause_i="1"/>
      <name name="log" arity="4" clause_i="2"/>
      <fsummary>Logs the given message.</fsummary>
      <type variable="Level"/>
      <type variable="StringOrReport" name_i="1"/>
      <type variable="Format" name_i="3"/>
      <type variable="Args" name_i="3"/>
      <type variable="Fun" name_i="4"/>
      <type variable="FunArgs" name_i="4"/>
      <type variable="Metadata"/>
      <desc>
        <p>Log the given message.</p>
      </desc>
    </func>

    <func>
      <name name="get_logger_config" arity="0"/>
      <fsummary>Lookup the current configuration for logger.</fsummary>
      <desc>
        <p>Lookup the current configuration for logger.</p>
      </desc>
    </func>

    <func>
      <name name="get_handler_config" arity="1"/>
      <fsummary>Lookup the current configuration for the given handler.</fsummary>
      <desc>
        <p>Lookup the current configuration for the given handler.</p>
      </desc>
    </func>

    <func>
      <name name="i" arity="0"/>
      <fsummary>Get information about all logger configurations</fsummary>
      <desc>
        <p>Same as <seealso marker="#i/1"><c>logger:i(term)</c></seealso></p>
      </desc>
    </func>

    <func>
      <name name="i" arity="1" clause_i="1"/>
      <name name="i" arity="1" clause_i="2"/>
      <name name="i" arity="1" clause_i="3"/>
      <fsummary>Get information about all logger configurations</fsummary>
      <desc>
        <p>The <c>logger:i/1</c> function can be used to get all
          current logger configuration.  The way that the information
          is returned depends on the <c><anno>Action</anno></c></p>
        <taglist>
          <tag>string</tag>
          <item>Return the pretty printed current logger configuration
            as iodata.</item>
          <tag>term</tag>
          <item>Return the current logger configuration as a term. The
            format of this term may change inbetween releases. For a
            stable format use <seealso marker="#get_handler_config/1">
	      <c>logger:get_handler_config/1</c></seealso>
            and <seealso marker="#get_logger_config/0">
	      <c>logger:get_logger_config/0</c></seealso>.
            The same as calling <c>logger:i()</c>.</item>
	  <tag>print</tag>
          <item>Pretty print all the current logger configuration to
            standard out. Example:
            <code><![CDATA[1> logger:i(print).
Current logger configuration:
  Level: info
  FilterDefault: log
  Filters:
  Handlers:
    Id: logger_std_h
      Module:    logger_std_h
      Level:     info
      Formatter:
        Module: logger_formatter
        Config: #{template => [{logger_formatter,header},"\n",msg,"\n"],
                  legacy_header => true}
      Filter Default: stop
      Filters:
        Id: stop_progress
          Fun:    fun logger_filters:progress/2
          Config: stop
        Id: remote_gl
          Fun:    fun logger_filters:remote_gl/2
          Config: stop
        Id: domain
          Fun:    fun logger_filters:domain/2
          Config: {log,prefix_of,[beam,erlang,otp,sasl]}
        Id: no_domain
          Fun:    fun logger_filters:domain/2
          Config: {log,no_domain,[]}
      Handler Config:
        logger_std_h: #{type => standard_io}
  Level set per module:
    Module: my_module
      Level:    debug]]></code>
          </item>
        </taglist>
      </desc>
    </func>

    <func>
      <name name="add_logger_filter" arity="2"/>
      <fsummary>Add a filter to the logger.</fsummary>
      <desc>
        <p>Add a filter to the logger.</p>
      </desc>
    </func>

    <func>
      <name name="add_handler_filter" arity="3"/>
      <fsummary>Add a filter to the specified handler.</fsummary>
      <desc>
        <p>Add a filter to the specified handler.</p>
      </desc>
    </func>

    <func>
      <name name="remove_logger_filter" arity="1"/>
      <fsummary>Remove a filter from the logger.</fsummary>
      <desc>
        <p>Remove the filter with the specified identity from the logger.</p>
      </desc>
    </func>

    <func>
      <name name="remove_handler_filter" arity="2"/>
      <fsummary>Remove a filter from the specified handler.</fsummary>
      <desc>
        <p>Remove the filter with the specified identity from the given handler.</p>
      </desc>
    </func>

    <func>
      <name name="add_handler" arity="3"/>
      <fsummary>Add a handler with the given configuration.</fsummary>
      <desc>
        <p>Add a handler with the given configuration.</p>
      </desc>
    </func>

    <func>
      <name name="remove_handler" arity="1"/>
      <fsummary>Remove the handler with the specified identity.</fsummary>
      <desc>
        <p>Remove the handler with the specified identity.</p>
      </desc>
    </func>

    <func>
      <name name="set_module_level" arity="2"/>
      <fsummary>Set the log level for the specified module.</fsummary>
      <desc>
        <p>Set the log level for the specified module.</p>
        <p>To change the logging level globally, use
        <seealso marker="#set_logger_config/2"><c>logger:set_logger_config(level, Level)</c></seealso>.
        </p>
      </desc>
    </func>

    <func>
      <name name="reset_module_level" arity="1"/>
      <fsummary>Remove a module specific log setting.</fsummary>
      <desc>
        <p>Remove a module specific log setting. After this, the
          global log level is used for the specified module.</p>
      </desc>
    </func>

    <func>
      <name name="set_logger_config" arity="1"/>
      <fsummary>Set configuration data for the logger.</fsummary>
      <desc>
        <p>Set configuration data for the logger. This overwrites the
          current logger configuration.</p>
	<p>To modify the existing configuration,
	  use <seealso marker="#set_logger_config-2"><c>set_logger_config/2</c>
	  </seealso>, or read the current configuration
	  with <seealso marker="#get_logger_config-0"><c>get_logger_config/0</c>
	  </seealso>, then merge in your added or updated
	  associations before writing it back.</p>
      </desc>
    </func>

    <func>
      <name name="set_logger_config" arity="2"/>
      <fsummary>Add or update configuration data for the logger.</fsummary>
      <desc>
        <p>Add or update configuration data for the logger. If the
          given <c><anno>Key</anno></c> already exists, its associated
          value will be set to <c><anno>Value</anno></c>. If it
          doesn't exist, it will be added.</p>
      </desc>
    </func>

    <func>
      <name name="set_handler_config" arity="2"/>
      <fsummary>Set configuration data for the specified handler.</fsummary>
      <desc>
        <p>Set configuration data for the specified handler. This
          overwrites the current handler configuration.</p>
	<p>To modify the existing configuration,
	  use <seealso marker="#set_handler_config-3"><c>set_handler_config/3</c>
	  </seealso>, or read the current configuration
	  with <seealso marker="#get_handler_config-1"><c>get_handler_config/1</c>
	  </seealso>, then merge in your added or updated
	  associations before writing it back.</p>
      </desc>
    </func>

    <func>
      <name name="set_handler_config" arity="3"/>
      <fsummary>Add or update configuration data for the specified
        handler.</fsummary>
      <desc>
        <p>Add or update configuration data for the specified
          handler. If the
          given <c><anno>Key</anno></c> already exists, its associated
          value will be set to <c><anno>Value</anno></c>. If it
          doesn't exist, it will be added.</p>
      </desc>
    </func>

    <func>
      <name name="compare_levels" arity="2"/>
      <fsummary>Compare the severity of two log levels.</fsummary>
      <desc>
        <p>Compare the severity of two log levels. Returns <c>gt</c>
          if <c>Level1</c> is more severe than
          <c>Level2</c>, <c>lt</c> if <c>Level1</c> is less severe,
          and <c>eq</c> if the levels are equal.</p>
      </desc>
    </func>

    <func>
      <name name="set_process_metadata" arity="1"/>
      <fsummary>Set metadata to use when logging from current process.</fsummary>
      <desc>
        <p>Set metadata which <c>logger</c> automatically inserts it
          in all log events produced on the current
          process. Subsequent calls will overwrite previous data set
          by this function.</p>
	<p>When logging, location data produced by the log macros,
	  and/or metadata given as argument to the log call (API
	  function or macro), will be merged with the process
	  metadata. If the same keys occur, values from the metadata
	  argument to the log call will overwrite values in the
	  process metadata, which in turn will overwrite values from
	  the location data.</p>
      </desc>
    </func>

    <func>
      <name name="get_process_metadata" arity="0"/>
      <fsummary>Retrieve data set with set_process_metadata/1.</fsummary>
      <desc>
        <p>Retrieve data set
          with <seealso marker="#set_process_metadata-1">
	    <c>set_process_metadata/1</c></seealso>.</p>
      </desc>
    </func>

    <func>
      <name name="unset_process_metadata" arity="0"/>
      <fsummary>Delete data set with set_process_metadata/1.</fsummary>
      <desc>
        <p>Delete data set
          with <seealso marker="#set_process_metadata-1">
	    <c>set_process_metadata/1</c></seealso>.</p>
      </desc>
    </func>

  </funcs>

</erlref>