@@ -64,7 +64,7 @@ Below is a list of all ``log`` functions.
64
64
65
65
* ``level ``: Specifies the level of detail the log has.
66
66
67
- Learn more: :ref: `log_level < cfg_logging-log_level >`.
67
+ Learn more: :ref: `log.level < configuration_reference_log_level >`.
68
68
69
69
* ``log ``: Specifies where to send the log's output, for example,
70
70
to a file, pipe, or system logger.
@@ -74,29 +74,26 @@ Below is a list of all ``log`` functions.
74
74
* ``nonblock ``: If **true **, Tarantool does not block during logging when the system
75
75
is not ready for writing, and drops the message instead.
76
76
77
- Learn more: :ref: `log_nonblock < cfg_logging-log_nonblock >`.
77
+ Learn more: :ref: `log.nonblock < configuration_reference_log_nonblock >`.
78
78
79
79
* ``format ``: Specifies the log format: 'plain' or 'json'.
80
80
81
- Learn more: :ref: `log_format < cfg_logging-log_format >`.
81
+ Learn more: :ref: `log.format < configuration_reference_log_format >`.
82
82
83
83
* ``modules ``: Configures the specified log levels for different modules.
84
84
85
- Learn more: :ref: `log_modules < cfg_logging-log_modules >`.
85
+ Learn more: :ref: `log.modules < configuration_reference_log_modules >`.
86
86
87
- The example below shows how to set the log level to 'debug' and how to send the resulting log
88
- to the 'tarantool.log' file:
87
+ **Example **
89
88
90
- .. code-block :: lua
89
+ The example below shows how to set the log level to `` verbose ``:
91
90
92
- log = require('log')
93
- log.cfg{ level='debug', log='tarantool.log'}
94
-
95
- .. NOTE ::
91
+ .. literalinclude :: /code_snippets/test/logging/log_test.lua
92
+ :language: lua
93
+ :start-at: local log = require
94
+ :end-at: log.cfg
95
+ :dedent:
96
96
97
- Note that calling ``log.cfg() `` before ``box.cfg() `` takes into account
98
- logging options specified using :ref: `environment variables <box-cfg-params-env >`,
99
- such as ``TT_LOG `` and ``TT_LOG_LEVEL ``.
100
97
101
98
.. _log-ug_message :
102
99
@@ -108,13 +105,16 @@ Below is a list of all ``log`` functions.
108
105
109
106
Log a message with the specified logging level.
110
107
You can learn more about the available levels from the
111
- :ref: `log_level <cfg_logging-log_level >` property description.
108
+ :ref: `log.level <configuration_reference_log_level >` option description.
109
+
110
+ **Example **
112
111
113
- The example below shows how to log a message with the ``info `` level:
112
+ The example below shows how to log a message with the ``warn `` level:
114
113
115
114
.. literalinclude :: /code_snippets/test/logging/log_test.lua
116
115
:language: lua
117
- :lines: 13-21
116
+ :start-at: log.warn
117
+ :end-at: log.warn
118
118
:dedent:
119
119
120
120
:param any message: A log message.
@@ -123,18 +123,19 @@ Below is a list of all ``log`` functions.
123
123
124
124
* A message may contain C-style format specifiers ``%d `` or ``%s ``. Example:
125
125
126
- .. code-block :: lua
127
-
128
- box.cfg{}
129
- log = require(' log')
130
- log.info('Info %s', box.info.version)
126
+ .. literalinclude :: /code_snippets/test/logging/log_test. lua
127
+ :language: lua
128
+ :start-at: log.info
129
+ :end-at: log.info
130
+ :dedent:
131
131
132
132
* A message may be a scalar data type or a table. Example:
133
133
134
- .. code-block :: lua
135
-
136
- log = require('log')
137
- log.error({500,'Internal error'})
134
+ .. literalinclude :: /code_snippets/test/logging/log_test.lua
135
+ :language: lua
136
+ :start-at: log.error
137
+ :end-at: log.error
138
+ :dedent:
138
139
139
140
:return: nil
140
141
@@ -146,7 +147,7 @@ Below is a list of all ``log`` functions.
146
147
* ``message ``
147
148
148
149
Note that the message will not be logged if the severity level corresponding to
149
- the called function is less than :ref: `log_level < cfg_logging-log_level >`.
150
+ the called function is less than :ref: `log.level < configuration_reference_log_level >`.
150
151
151
152
.. _log-pid :
152
153
@@ -176,28 +177,32 @@ Below is a list of all ``log`` functions.
176
177
:param string name: a logger name
177
178
:return: a logger instance
178
179
179
- **Example: **
180
+ **Example **
180
181
181
- The code snippet below shows how to set the ``verbose `` level for ``module1 `` and the ``error `` level for ``module2 ``:
182
+ This example shows how to set the ``verbose `` level for ``module1 `` and the ``error `` level for ``module2 `` in a configuration file :
182
183
183
- .. literalinclude :: /code_snippets/test/logging/log_new_modules_test.lua
184
- :language: lua
185
- :lines: 9-13
184
+ .. literalinclude :: /code_snippets/snippets/config/instances.enabled/log_new_modules/config.yaml
185
+ :language: yaml
186
+ :start-at: log:
187
+ :end-at: app.lua
186
188
:dedent:
187
189
188
- To create the ``module1 `` and ``module2 `` loggers, call the ``new() `` function:
190
+ To create the ``module1 `` and ``module2 `` loggers in your application (`` app.lua ``) , call the ``new() `` function:
189
191
190
- .. literalinclude :: /code_snippets/test/logging/log_new_modules_test .lua
192
+ .. literalinclude :: /code_snippets/snippets/config/instances.enabled/log_new_modules/app .lua
191
193
:language: lua
192
- :lines: 17-19
194
+ :start-at: Creates new loggers
195
+ :end-at: module2_log = require
193
196
:dedent:
194
197
195
198
Then, you can call functions corresponding to different logging levels to make sure
196
199
that events with severities above or equal to the given levels are shown:
197
200
198
- .. literalinclude :: /code_snippets/test/logging/log_new_modules_test .lua
201
+ .. literalinclude :: /code_snippets/snippets/config/instances.enabled/log_new_modules/app .lua
199
202
:language: lua
200
- :lines: 21-41
203
+ :start-after: module2_log = require
201
204
:dedent:
202
205
203
206
At the same time, the events with severities below the specified levels are swallowed.
207
+
208
+ Example on GitHub: `log_new_modules <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/log_new_modules >`_.
0 commit comments