Skip to content

Commit 327ac30

Browse files
committed
Document logging settings
Resolves #1974
1 parent 0772a0e commit 327ac30

File tree

2 files changed

+48
-33
lines changed

2 files changed

+48
-33
lines changed

doc/reference/configuration/cfg_logging.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
.. _cfg_logging:
22

3+
This section provides information on how to configure options related to logging.
4+
You can also use the :ref:`log module <log-module>` to configure logging in your
5+
application.
6+
37
* :ref:`log_level <cfg_logging-log_level>`
48
* :ref:`log <cfg_logging-log>`
59
* :ref:`log_nonblock <cfg_logging-log_nonblock>`

doc/reference/reference_lua/log.rst

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,12 @@
1010
Overview
1111
===============================================================================
1212

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.
4419

4520
===============================================================================
4621
Index
@@ -56,12 +31,15 @@ Below is a list of all ``log`` functions.
5631
+--------------------------------------+---------------------------------+
5732
| Name | Use |
5833
+======================================+=================================+
34+
| :ref:`log.cfg({}) | Configure a logger |
35+
| <log-cfg>` | |
36+
+--------------------------------------+---------------------------------+
5937
| :ref:`log.error() | |
6038
| <log-ug_message>` |br| | |
6139
| :ref:`log.warn() | |
6240
| <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 |
6543
| :ref:`log.verbose() | |
6644
| <log-ug_message>` |br| | |
6745
| :ref:`log.debug() | |
@@ -74,6 +52,39 @@ Below is a list of all ``log`` functions.
7452
| <log-rotate>` | |
7553
+--------------------------------------+---------------------------------+
7654

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+
7788
.. _log-ug_message:
7889

7990
.. function:: error(message)

0 commit comments

Comments
 (0)