-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log: introduce per-module log_level
#7672
log: introduce per-module log_level
#7672
Conversation
c95d748
to
1d2d19b
Compare
1d2d19b
to
fc96a76
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it difficult to review this PR because of how it's split. I think it should be re-split as follows:
- Add
log.new()
function that creates a new log module. The function should take the module name and the log level. - Add a utility module/function that can be usd to extract the module name from the file name or stack (the code that's currently located in
src/lua/init.lua
). - Implement automatic module name deduction in
log.new()
(something likelog.new({module = 'auto'})
). - Add new global log options.
- Allow the user to enable automatic module name deduction via
log.cfg()
. - Allow the user to set per-module log level via
log.cfg()
by passing a map{name->level} foropts.level
.
- Allow the user to enable automatic module name deduction via
- Implement the box API mapping for the new log options.
Each part should be covered with tests.
We also need to agree on the names (the current API looks a bit awkward to me).
fc96a76
to
36b8c48
Compare
3381a77
to
e5f2255
Compare
f6282fa
to
ab4bb03
Compare
45558d3
to
d18da53
Compare
Cartridge tests use some dirty magic, which doesn't work with Filed an issue: tarantool/cartridge#1998 |
It allows to create a new instance of a log module, with a custom name: local my_log = require('log').new('my_module') The name is added to the log message after fiber name: YYYY-MM-DD hh:mm:ss.ms [PID]: CORD/FID/FIBERNAME/MODULENAME LEVEL> MSG Part of tarantool#3211 NO_DOC=See next commit NO_CHANGELOG=See next commit Co-authored-by: AnastasMIPT <beliaev.ab@tarantool.org>
Now it is possible to specify the log level for each module separately, e.g.: box.cfg { log_level = 5, log_modules = { ['foo.bar'] = 1, expirationd = 'debug' } } Part of tarantool#3211 NO_DOC=See next commit NO_CHANGELOG=See next commit Co-authored-by: AnastasMIPT <beliaev.ab@tarantool.org>
Now the name of a module, from which the logging function was called, is determined automatically during the execution of `require('log')` in the module's source code. This is implemented by overriding the built-in `require` function. Part of tarantool#3211 NO_DOC=See next commit NO_CHANGELOG=See next commit Co-authored-by: AnastasMIPT <beliaev.ab@tarantool.org>
Closes tarantool#3211 NO_TEST=Documentation @TarantoolBot document Title: Per-module log level Root document: https://www.tarantool.io/en/doc/latest/reference/configuration/#logging Since version 2.11 it is possible to specify the log level for each module separately, e.g.: box.cfg { log_level = 5, log_modules = { ['foo.bar'] = 1, expirationd = 'debug' } } The name of a module is determined automatically during the execution of `require('log')` in the module's source code. The name is derived from its filename, including a part of the path. Also it is possible to create a logger with a custom name by using `log.new()`. --- Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/log/ New function: log.new(name) Creates a new logger with a custom name. Parameter `name`: Type: string Optional: false Example: box.cfg{log_level='error', log_modules={my_module='info'}} log = require('log') my_log = log.new('my_module') my_log.info('Info')
d18da53
to
9ba8167
Compare
log: add log.new() function that creates a new logger
It allows to create a new instance of a log module, with a custom name, e.g.:
The name is added to the log message after fiber name:
log: add per-module log level setting via log.cfg() or box.cfg()
Now it is possible to specify the log level for each module separately, e.g.:
The name of a module is determined automatically, or it is possible to create a logger with a custom name by using
log.new()
.log: implement automatic module name deduction
The name of a module is determined automatically during the execution of
require('log')
in the module's source code. The name is derived from its filename, including a part of the path. This is implemented by overriding the built-inrequire
function.Closes #3211