From de41e1737b6014f651ad8beb08519b3ccbcc34d1 Mon Sep 17 00:00:00 2001 From: Michael Opdenacker Date: Fri, 27 Jan 2023 19:28:24 +0100 Subject: bitbake: bitbake-user-manual: show how use BB_LOGCONFIG to log warnings (Bitbake rev: 22be2dbd8e70322239f70e53ace2a552425e3665) Signed-off-by: Michael Opdenacker Suggested-by: Joshua Watt Signed-off-by: Richard Purdie --- .../bitbake-user-manual-execution.rst | 45 ++++++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'bitbake') diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst index f6ebf7ba6a..4fa3ca4b54 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst @@ -656,7 +656,7 @@ builds are when execute, bitbake also supports user defined configuration of the `Python logging `__ facilities through the :term:`BB_LOGCONFIG` variable. This -variable defines a json or yaml `logging +variable defines a JSON or YAML `logging configuration `__ that will be intelligently merged into the default configuration. The logging configuration is merged using the following rules: @@ -690,9 +690,9 @@ logging configuration is merged using the following rules: adds a filter called ``BitBake.defaultFilter``, both filters will be applied to the logger -As an example, consider the following user logging configuration file -which logs all Hash Equivalence related messages of VERBOSE or higher to -a file called ``hashequiv.log`` :: +As a first example, you can create a ``hashequiv.json`` user logging +configuration file to log all Hash Equivalence related messages of ``VERBOSE`` +or higher priority to a file called ``hashequiv.log``:: { "version": 1, @@ -721,3 +721,40 @@ a file called ``hashequiv.log`` :: } } } + +Then set the :term:`BB_LOGCONFIG` variable in ``conf/local.conf``:: + + BB_LOGCONFIG = "hashequiv.json" + +Another example is this ``warn.json`` file to log all ``WARNING`` and +higher priority messages to a ``warn.log`` file:: + + { + "version": 1, + "formatters": { + "warnlogFormatter": { + "()": "bb.msg.BBLogFormatter", + "format": "%(levelname)s: %(message)s" + } + }, + + "handlers": { + "warnlog": { + "class": "logging.FileHandler", + "formatter": "warnlogFormatter", + "level": "WARNING", + "filename": "warn.log" + } + }, + + "loggers": { + "BitBake": { + "handlers": ["warnlog"] + } + }, + + "@disable_existing_loggers": false + } + +Note that BitBake's helper classes for structured logging are implemented in +``lib/bb/msg.py``. -- cgit v1.2.3-54-g00ecf