diff --git a/documentation/poky-ref-manual/usingpoky.xml b/documentation/poky-ref-manual/usingpoky.xml index b36526e919..976f7f4c11 100644 --- a/documentation/poky-ref-manual/usingpoky.xml +++ b/documentation/poky-ref-manual/usingpoky.xml @@ -375,20 +375,28 @@ Best practices exist while writing recipes that both log build progress and act on build conditions such as warnings and errors. - Depending whether you are creating recipes using Bash or Python, the mechanism - differs: + Both Python and Bash language bindings exist for the logging mechanism: - Python: For Python functions BitBake + Python: For Python functions, BitBake supports several loglevels: bb.fatal, bb.error, bb.warn, bb.note, bb.plain, and bb.debug. - Bash: For Bash functions you use the - echo command and prepend a diagnostic string that includes - the loglevel followed by a colon character + Bash: For Bash functions, the same set + of loglevels exist and are accessed with a similar syntax: + bb.fatal, bb.error, + bb.warn, bb.note, + bb.plain, and bb.debug. + + For guidance on echo how logging is handled + in both Python and Bash recipes, see the + logging.bbclass file in the + meta/classes directory of the Yocto Project files. + +
Logging With Python @@ -426,14 +434,8 @@ When creating recipes using Bash and inserting code that handles build logs you have the same goals - informative with minimal console output. - Use the echo command and prepend the diagnostic string - with the appropriate loglevel floowed by the colon character. - - - - For guidance on echo usage in Bash recipes, see the - logging.bbclass file in the - meta/classes directory of the Yocto Project files. + The syntax you use for recipes written in Bash is similar to that of + recipes written in Python described in the previous section. @@ -441,21 +443,21 @@ The code logs the progress of the do_my_function function. do_my_function() { - echo "Running do_my_function()" + bbdebug 2 "Running do_my_function" if [ exceptional_condition ]; then - echo "NOTE: hit exceptional_condition" + bbnote "Hit exceptional_condition" fi - echo "DEBUG: got to point xyz" + bbdebug 2 "Got to point xyz" if [ warning_trigger ]; then - echo "WARNING: detected warning_trigger, this might cause a plroblem later." + warn "Detected warning_trigger, this might cause a problem later." fi if [ recoverable_error ]; then - echo "ERROR: hit recoverable_error, correcting" + error "Hit recoverable_error, correcting" fi if [ fatal_error ]; then - echo "FATAL: fatal_error detected" + fatal "fatal_error detected" fi - echo "Completed do_my_function" + debug 2 "Completed do_my_function" }