@@ -57,10 +57,11 @@ Below is a list of all ``log`` functions.
57
57
.. function :: log.cfg({})
58
58
59
59
Allows you to configure logging options.
60
- The following logging options are available:
60
+ The following options are available:
61
61
62
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 >`.
63
+
64
+ See also: :ref: `log_level <cfg_logging-log_level >`.
64
65
65
66
* ``log ``: Specifies where to to send the log's output, for example,
66
67
to a file, pipe, or system logger.
@@ -73,10 +74,9 @@ Below is a list of all ``log`` functions.
73
74
See also: :ref: `log_nonblock <cfg_logging-log_nonblock >`
74
75
75
76
* ``format ``: Specifies the log format: 'plain' or 'json'.
76
-
77
77
See also: :ref: `log_format <cfg_logging-log_format >`
78
78
79
- The example below shows how set the log level to 'debug' and how to send the resulting log
79
+ The example below shows how to set the log level to 'debug' and how to send the resulting log
80
80
to the 'tarantool.log' file:
81
81
82
82
.. code-block :: lua
@@ -93,36 +93,38 @@ Below is a list of all ``log`` functions.
93
93
verbose(message)
94
94
debug(message)
95
95
96
- Output a user-generated message to the :ref: `log file <cfg_logging-log >`,
97
- given log_level_function_name = ``error `` or ``warn `` or ``info `` or
98
- ``verbose `` or ``debug ``.
96
+ Logs a message with the specified logging level.
97
+ You can learn more about the available levels from the
98
+ :ref: `log_level <cfg_logging-log_level >` property description.
99
+
100
+ The example below shows how to log a message with the ``info `` level:
101
+
102
+ .. code-block :: lua
103
+
104
+ log = require('log')
105
+ log.info('Hello, world!')
106
+
107
+ :param any message: A log message.
99
108
100
- As explained in the description of the configuration setting for
101
- :ref: `log_level <cfg_logging-log_level >`, there are seven levels of detail:
109
+ * A message can be a string.
102
110
103
- * 1 – ``SYSERROR ``
104
- * 2 – ``ERROR `` -- this corresponds to ``log.error(...) ``
105
- * 3 – ``CRITICAL ``
106
- * 4 – ``WARNING `` -- this corresponds to ``log.warn(...) ``
107
- * 5 – ``INFO `` -- this corresponds to ``log.info(...) ``
108
- * 6 – ``VERBOSE `` -- this corresponds to ``log.verbose(...) ``
109
- * 7 – ``DEBUG `` -- this corresponds to ``log.debug(...) ``
111
+ * A messages may contain C-style format specifiers ``%d `` or
112
+ ``%s ``. Example:
110
113
111
- For example, if ``box.cfg.log_level `` is currently 5 (the default value),
112
- then ``log.error(...) ``, ``log.warn(...) `` and ``log.info(...) `` messages
113
- will go to the log file. However, ``log.verbose(...) `` and
114
- ``log.debug(...) `` messages will not go to the log file, because they
115
- correspond to higher levels of detail.
114
+ .. code-block :: lua
116
115
117
- :param any message: Usually a string.
116
+ box.cfg{}
117
+ log = require('log')
118
+ log.info('Info %s', box.info.version)
118
119
119
- Messages may contain C-style format specifiers %d or
120
- %s, so :samp: `log.error('...%d...%s', { x } , { y } ) `
121
- will work if ``x `` is a number and ``y `` is a string.
120
+ * A message may be other scalar data types,
121
+ or even tables. Example:
122
122
123
- Less commonly, messages may be other scalar data types,
124
- or even tables. So :code: `log.error({'x',18.7,true}) `
125
- will work.
123
+ .. code-block :: lua
124
+
125
+ box.cfg{}
126
+ log = require('log')
127
+ log.error({500,'Internal error'})
126
128
127
129
:return: nil
128
130
@@ -141,36 +143,12 @@ Below is a list of all ``log`` functions.
141
143
142
144
.. function :: logger_pid()
143
145
144
- :return: PID of a logger
146
+ :return: Returns a PID of a logger.
145
147
146
148
.. _log-rotate :
147
149
148
150
.. function :: rotate()
149
151
150
- Rotate the log.
152
+ Rotates the log.
151
153
152
154
:return: nil
153
-
154
- =================================================
155
- Example
156
- =================================================
157
-
158
- .. code-block :: tarantoolsession
159
-
160
- $ tarantool
161
- tarantool> box.cfg{log_level=3, log='tarantool.txt'}
162
- tarantool> log = require('log')
163
- tarantool> log.error('Error')
164
- tarantool> log.info('Info %s', box.info.version)
165
- tarantool> os.exit()
166
-
167
- .. code-block :: console
168
-
169
- $ less tarantool.txt
170
- 2017-09-20 ... [68617] main/101/interactive C> version 1.7.5-31-ge939c6ea6
171
- 2017-09-20 ... [68617] main/101/interactive C> log level 3
172
- 2017-09-20 ... [68617] main/101/interactive [C]:-1 E> Error
173
-
174
- The 'Error' line is visible in ``tarantool.txt `` preceded by the letter E.
175
-
176
- The 'Info' line is not present because the ``log_level `` is 3.
0 commit comments