Skip to content
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.info does not emit file name and line in plain format #9913

Open
locker opened this issue Apr 5, 2024 · 0 comments
Open

log.info does not emit file name and line in plain format #9913

locker opened this issue Apr 5, 2024 · 0 comments
Labels
bug Something isn't working logger Issues related to logging subsystem

Comments

@locker
Copy link
Member

locker commented Apr 5, 2024

Reproduced with 3.1.0-entrypoint-227-gde80e0264f7d, but it looks like the bug has been there for ages.

Reproducer:

local log = require('log')
log.cfg{log = 'log.txt'}
log.info('foo')
log.warn('bar')
log.error('buzz')

Log:

2024-04-05 17:44:33.878 [56006] main/104/test.lua/test I> foo
2024-04-05 17:44:33.878 [56006] main/104/test.lua/test test.lua:4 W> bar
2024-04-05 17:44:33.878 [56006] main/104/test.lua/test test.lua:5 E> buzz

Note that the info message lacks the file name and line. This is especially annoying in the scope of PR tarantool/luatest#347, which improved logging in luatest: the PR uses the info log level for logging assertions, which means that they won't include the file name and line.

Interestingly, this bug only affects the plain log format. In the json log format, the file name and line are emitted unconditionally:

local log = require('log')
log.cfg{log = 'log.txt', format = 'json'}
log.info('foo')
log.warn('bar')
log.error('buzz')

Log:

{"time": "2024-04-05T17:51:52.305+0300", "level": "INFO", "message": "foo", "pid": 56131 , "cord_name": "main", "fiber_id": 104, "fiber_name": "test.lua", "file": "test.lua", "line": 3, "module": "test"}
{"time": "2024-04-05T17:51:52.305+0300", "level": "WARN", "message": "bar", "pid": 56131 , "cord_name": "main", "fiber_id": 104, "fiber_name": "test.lua", "file": "test.lua", "line": 4, "module": "test"}
{"time": "2024-04-05T17:51:52.305+0300", "level": "ERROR", "message": "buzz", "pid": 56131 , "cord_name": "main", "fiber_id": 104, "fiber_name": "test.lua", "file": "test.lua", "line": 5, "module": "test"}
@locker locker added bug Something isn't working logger Issues related to logging subsystem labels Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working logger Issues related to logging subsystem
Projects
None yet
Development

No branches or pull requests

1 participant