Adding logging to recipes

BitBake recipes accept either Bash or Python code. Python logging is done through the bb class and uses the standard logging Python library module. It has the following components:

  • bb.plain: This uses logger.plain. It can be used for debugging, but should not be committed to the source.
  • bb.note: This uses logger.info.
  • bb.warn: This uses logger.warn.
  • bb.error: This uses logger.error.
  • bb.fatal: This uses logger.critical and exits BitBake.
  • bb.debug: This should be passed a log level as the first argument and uses logger.debug.

To print debug output from Bash in our recipes, we need to use the logging class by executing:

inherit logging  

The logging class is inherited by default by all recipes containing base.bbclass, so we don't usually have to inherit it explicitly. We will then have access to the following Bash functions:

  • bbplain: This function outputs literally what's passed in. It can be used in debugging but should not be committed to a recipe source.
  • bbnote: This function prints with the NOTE prefix.
  • bbwarn: This prints a non-fatal warning with the WARNING prefix.
  • bberror: This prints a non-fatal error with the ERROR prefix.
  • bbfatal: This function halts the build and prints an error message as with bberror.
  • bbdebug: This function prints debug messages with the log level passed as the first argument. It is used with the following format:
bbdebug [123] "message"
The Bash functions mentioned here do not log to the console but only to the log files.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset