Bug 9950 - Suggested additions to the logging documentation
Summary: Suggested additions to the logging documentation
Status: RESOLVED FIXED
Alias: None
Product: Reference
Classification: Documentation
Component: handbook (show other bugs)
Version: 2.3
Hardware: x86 Multiple
: Undecided normal
Target Milestone: 2.2 M4
Assignee: Scott Rifenbark
QA Contact:
URL:
Whiteboard: 18 July 2016: RESOLVED
Depends on:
Blocks:
 
Reported: 2016-07-15 10:51 UTC by ulfalizer
Modified: 2016-07-18 17:36 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Done (doc changes complete)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ulfalizer 2016-07-15 10:51:29 UTC
Much of the logging functionality is undocumented at the moment. I suggest the following additions to the BitBake user manual and the Yocto Project Reference Manual.

***Change 1***

In the BitBake User Manual, change the following,

       -v, --verbose         Output more log message data to the terminal.
       -D, --debug           Increase the debug level. You can specify this more
                             than once.

, to the following:

       -v, --verbose         Enable tracing of shell tasks (with 'set -x').
                             Also print bb.note(...) messages to stdout (in
                             addition to writing them to ${T}/log.do_<task>).
       -D, --debug           Increase the debug level. You can specify this
                             more than once. -D sets the debug level to 1,
                             where only bb.debug(1, ...) messages are printed
                             to stdout; -DD sets the debug level to 2, where
                             both bb.debug(1, ...) and bb.debug(2, ...)
                             messages are printed; etc. Without -D, no debug
                             messages are printed. Note that -D only affects
                             output to stdout. All debug messages are written
                             to ${T}/log.do_taskname, regardless of the debug
                             level.

***Change 2***

Fix typo in https://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#var-BBDEBUG. "... -d command line option" should be "... -D command line option".

***Change 3***

In the Yocto Project Reference manual, replace the contents of 2.3.8. Recipe Logging Mechanisms with the following. This removes "best practices exist while writing recipes that both log build progress and act on build conditions such as warnings and errors" and the reference to logging.bbclass, but I think that's okay.


For Python functions, the following logging functions exist. All of these
functions log to ${T}/log.do_<task>, and can also log to stdout with the right
settings.

  * bb.plain(<msg>):
        Writes <msg> as-is to the log, also logging to stdout.

  * bb.note(<msg>):
        Writes "NOTE: <msg>" to the log. Also logs to stdout if bitbake is called
        with -v.

  * bb.debug(<level>, <msg>):
        Writes "DEBUG: <msg>" to the log. Also logs to stdout if the log level is
        greater than or equal to <level>: See the -D option in the (bitbake command
        overview)[https://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#usage-and-syntax].

  * bb.warn(<msg>):
        Writes "WARNING: <msg>" to the log, also logging to stdout.

  * bb.error(<msg>):
        Writes "ERROR: <msg>" to the log, also logging to stdout. Note that
        calling this function does not cause the task to fail.

  * bb.fatal(<msg>):
        Like bb.error(<msg>), but also causes the calling task to fail.

The same logging functions are also available in shell functions, under the
names 'bbplain', 'bbnote', 'bbdebug', 'bbwarn', 'bberror', and 'bbfatal'.
Comment 1 Scott Rifenbark 2016-07-16 19:55:14 UTC
Ulf, 

Change 1:  This change needs to be made to reflect the screen output when a user enters "bitbake -h".  The manual is reflecting the code here.  So I suggest filing a bug against the actual help output for the bitbake command.  When you file that, mark the dog flag as "yes" so I will see that the output in the manual needs updated as well.

Change 2: Fixed the -d to -D - see http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#var-BBDEBUG

Change 3: This was a more complicated change.  I did not want to just substitute that entire block for that fragment of the first paragraph.  We really need some sort of introductory sentence to start the section with.  So, you will see that I left the general start of the section.  Then I put in the changes you suggested.  I was unclear what to do with the existing two-bullet list that generally mentioned "Python" and "Bash", so I removed them in favor of the more detailed stuff you provided.  Also, was not sure how you were suggesting to end the section.  So... check it out and let me know. 

http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#recipe-logging-mechanisms

Thanks,
Scott
Comment 2 ulfalizer 2016-07-17 08:35:31 UTC
(In reply to comment #1)
> Ulf, 
> 
> Change 1:  This change needs to be made to reflect the screen output when a
> user enters "bitbake -h".  The manual is reflecting the code here.  So I
> suggest filing a bug against the actual help output for the bitbake command.
> When you file that, mark the dog flag as "yes" so I will see that the output
> in the manual needs updated as well.

Alright. I filed a separate ticket at
https://bugzilla.yoctoproject.org/show_bug.cgi?id=9962.
 
> Change 3: This was a more complicated change.  I did not want to just
> substitute that entire block for that fragment of the first paragraph.  We
> really need some sort of introductory sentence to start the section with. 
> So, you will see that I left the general start of the section.  Then I put
> in the changes you suggested.  I was unclear what to do with the existing
> two-bullet list that generally mentioned "Python" and "Bash", so I removed
> them in favor of the more detailed stuff you provided.

Yeah, might be nice to have an introductory sentence, but to be honest I have
no idea what the current one is trying to say :). Maybe it could be replaced
with

  Yocto provides several logging functions for producing debugging output
  and reporting errors and warnings.

> Also, was not sure how you were suggesting to end the section. 
> So... check it out and let me know. 

I just noticed there's separate documentation for logging.bbclass. Maybe this
would work:

  The same logging functions are also available in shell functions, under
  the names bbplain, bbnote, bbdebug, bbwarn, bberror, and bbfatal. These
  are implemented in
  [logging.bbclass](http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#ref-classes-logging).
Comment 3 Scott Rifenbark 2016-07-18 17:22:16 UTC
Ulf, 

See http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#recipe-logging-mechanisms for the modifications and let me know if we are good on this bug now. 

Thanks, 
Scott
Comment 4 ulfalizer 2016-07-18 17:30:15 UTC
Looks good to me!

Thanks,
Ulf
Comment 5 Scott Rifenbark 2016-07-18 17:36:09 UTC
Thanks, 

Reset to RESOLVED and marked doc flag to "Done."

Scott