10
10
Overview
11
11
===============================================================================
12
12
13
- The ``log `` module provides the event logging system for the Tarantool server.
14
- Tarantool puts all diagnostic messages in a log specified by
15
- the :ref: `log <cfg_logging-log >` configuration parameter. Diagnostic
16
- messages may be either system-generated by the server's internal code, or
17
- user-generated using the dedicated functions: ``log.info() ``, ``log.error() ``, and so on.
18
-
19
- As explained in the description of :ref: `log_format <cfg_logging-log_format >`
20
- configuration setting, there are two possible formats for log entries:
21
-
22
- * 'plain' (the default), or
23
- * 'json' (with more detail and with JSON labels).
24
-
25
- Here is what a log entry looks like after ``box.cfg{log_format='plain'} ``:
26
-
27
- .. code-block :: text
28
-
29
- 2017-10-16 11:36:01.508 [18081] main/101/interactive I> set 'log_format' configuration option to "plain"
30
-
31
- Here is what a log entry looks like after ``box.cfg{log_format='json'} ``:
32
-
33
- .. code-block :: text
34
-
35
- {"time": "2017-10-16T11:36:17.996-0600",
36
- "level": "INFO",
37
- "message": "set 'log_format' configuration option to \"json\"",
38
- "pid": 18081,|
39
- "cord_name": "main",
40
- "fiber_id": 101,
41
- "fiber_name": "interactive",
42
- "file": "builtin\/box\/load_cfg.lua",
43
- "line": 317}
13
+ Tarantool provides a set of :ref: `options <cfg_logging >` used to configure logging
14
+ in various ways: you can set a level of logging, specify where to send the log's output,
15
+ configure a log format, and so on.
16
+ The ``log `` module allows you to configure logging in you application and
17
+ provides additional capabilities, for example, logging custom messages and
18
+ rotating log files.
44
19
45
20
===============================================================================
46
21
Index
@@ -56,12 +31,15 @@ Below is a list of all ``log`` functions.
56
31
+--------------------------------------+---------------------------------+
57
32
| Name | Use |
58
33
+======================================+=================================+
34
+ | :ref: `log.cfg({}) | Configure a logger |
35
+ | <log-cfg>` | |
36
+ +--------------------------------------+---------------------------------+
59
37
| :ref: `log.error() | |
60
38
| <log-ug_message>` |br | | |
61
39
| :ref: `log.warn() | |
62
40
| <log-ug_message>` |br | | |
63
- | :ref: `log.info() | Write a user-generated message |
64
- | <log-ug_message>` |br | | to a log file |
41
+ | :ref: `log.info() | Log a message with the |
42
+ | <log-ug_message>` |br | | specified level |
65
43
| :ref: `log.verbose() | |
66
44
| <log-ug_message>` |br | | |
67
45
| :ref: `log.debug() | |
@@ -74,6 +52,39 @@ Below is a list of all ``log`` functions.
74
52
| <log-rotate>` | |
75
53
+--------------------------------------+---------------------------------+
76
54
55
+ .. _log-cfg :
56
+
57
+ .. function :: log.cfg({})
58
+
59
+ Allows you to configure logging options.
60
+ The following logging options are available:
61
+
62
+ * ``level ``: Specifies the level of detail the log has.
63
+ This property has the same effect as :ref: `log_level <cfg_logging-log_level >`.
64
+
65
+ * ``log ``: Specifies where to to send the log's output, for example,
66
+ to a file, pipe, or system logger.
67
+
68
+ See also: :ref: `log <cfg_logging-log >`
69
+
70
+ * ``nonblock ``: If **true **, Tarantool does not block during logging when the system
71
+ is not ready for writing, and drops the message instead.
72
+
73
+ See also: :ref: `log_nonblock <cfg_logging-log_nonblock >`
74
+
75
+ * ``format ``: Specifies the log format: 'plain' or 'json'.
76
+
77
+ See also: :ref: `log_format <cfg_logging-log_format >`
78
+
79
+ The example below shows how set the log level to 'debug' and how to send the resulting log
80
+ to the 'tarantool.log' file:
81
+
82
+ .. code-block :: lua
83
+
84
+ log = require('log')
85
+ log.cfg{ level='debug', log='tarantool.log'}
86
+
87
+
77
88
.. _log-ug_message :
78
89
79
90
.. function :: error(message)
0 commit comments