Skip to content

Per-module logging #3590

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

Merged
merged 1 commit into from
Aug 1, 2023
Merged

Per-module logging #3590

merged 1 commit into from
Aug 1, 2023

Conversation

andreyaksenov
Copy link
Contributor

@andreyaksenov andreyaksenov commented Jul 20, 2023

  • Added the description for the box.cfg.log_modules configuration property.
  • Added the log.new() function description to the log module API reference.
  • Added a note that environment variables are taken into account if log.cfg() is called before box.cfg().

Note that doc code snippets are included from testable examples placed in the doc/code_snippets folder for making sure they are correct and runnable.

@andreyaksenov andreyaksenov linked an issue Jul 20, 2023 that may be closed by this pull request
@andreyaksenov andreyaksenov force-pushed the 2.11-per-module-logging branch 3 times, most recently from b49fd42 to 0384785 Compare July 20, 2023 13:03
@andreyaksenov andreyaksenov linked an issue Jul 20, 2023 that may be closed by this pull request
@andreyaksenov andreyaksenov force-pushed the 2.11-per-module-logging branch from 0384785 to 6fb2673 Compare July 20, 2023 13:37
@andreyaksenov andreyaksenov requested a review from Gumix July 20, 2023 14:00
@andreyaksenov andreyaksenov force-pushed the 2.11-per-module-logging branch 2 times, most recently from d49d02b to dda9ec9 Compare July 21, 2023 12:41
Copy link
Contributor

@Gumix Gumix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following points from #3264 are missed:

It is possible to set custom log levels for files (modules) that just use default logger without creating a new instance by log.new()

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.

Example: https://github.com/tarantool/tarantool/blob/fa6ae4a3c366f7fec3fd57403bca313cf762904e/test/box-luatest/gh_3211_module/testmod.lua

https://github.com/tarantool/tarantool/blob/fa6ae4a3c366f7fec3fd57403bca313cf762904e/test/box-luatest/gh_3211_per_module_log_level_test.lua#L175-L179

There is a special module name "tarantool", which allows to set log level for Tarantool core messages. To be more precise, it sets log level for all messages logged from the non-Lua code, including user C modules.

Example: https://github.com/tarantool/tarantool/blob/fa6ae4a3c366f7fec3fd57403bca313cf762904e/test/box-luatest/gh_3211_per_module_log_level_test.lua#L190-L194

@andreyaksenov andreyaksenov force-pushed the 2.11-per-module-logging branch 6 times, most recently from f7c7f04 to d77b32b Compare August 1, 2023 09:29
@andreyaksenov
Copy link
Contributor Author

Thanks! Updated the docs as follows to reflect missed points:

  • Updated the box.cfg.log_modules description to show that different module types are supported.
  • Added 3 examples for all module types (file, custom, and tarantool).
  • Added the modules property to the log.cfg({}) description.

@andreyaksenov andreyaksenov requested a review from Gumix August 1, 2023 09:56
@andreyaksenov andreyaksenov requested a review from xuniq August 1, 2023 12:20

Note that calling ``log.cfg()`` before ``box.cfg()`` takes into account
logging options specified using :ref:`environment variables <box-cfg-params-env>`,
such as ``TT_LOG``, ``TT_LOG_LEVEL``, and so on.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
such as ``TT_LOG``, ``TT_LOG_LEVEL``, and so on.
such as ``TT_LOG`` and ``TT_LOG_LEVEL``.

:lines: 9-13
:dedent:

To create the ``module1`` and ``module1`` modules, call the ``new()`` function:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To create the ``module1`` and ``module1`` modules, call the ``new()`` function:
To create the ``module1`` and ``module2`` loggers, call the ``new()`` function:

@andreyaksenov andreyaksenov force-pushed the 2.11-per-module-logging branch from d77b32b to 4e3d482 Compare August 1, 2023 13:59
@andreyaksenov andreyaksenov force-pushed the 2.11-per-module-logging branch from 4e3d482 to 1ce1f6e Compare August 1, 2023 14:00
@andreyaksenov andreyaksenov merged commit a1d5352 into latest Aug 1, 2023
@andreyaksenov andreyaksenov deleted the 2.11-per-module-logging branch August 1, 2023 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

log: take into account env vars on log.cfg call Per-module log level
3 participants