documentation/poky-ref-manual/usingpoky.xml: Updated logging mechanism
Per Darren's feedback on this new section I updated changes based on his comments. (From yocto-docs rev: a5bbba42ec0da5b2f83f7a64ac8eef466e9c89b3) Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
ba3069c9c6
commit
d67201e600
|
@ -375,20 +375,28 @@
|
||||||
<para>
|
<para>
|
||||||
Best practices exist while writing recipes that both log build progress and
|
Best practices exist while writing recipes that both log build progress and
|
||||||
act on build conditions such as warnings and errors.
|
act on build conditions such as warnings and errors.
|
||||||
Depending whether you are creating recipes using Bash or Python, the mechanism
|
Both Python and Bash language bindings exist for the logging mechanism:
|
||||||
differs:
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem><para><emphasis>Python:</emphasis> For Python functions BitBake
|
<listitem><para><emphasis>Python:</emphasis> For Python functions, BitBake
|
||||||
supports several loglevels: <filename>bb.fatal</filename>,
|
supports several loglevels: <filename>bb.fatal</filename>,
|
||||||
<filename>bb.error</filename>, <filename>bb.warn</filename>,
|
<filename>bb.error</filename>, <filename>bb.warn</filename>,
|
||||||
<filename>bb.note</filename>, <filename>bb.plain</filename>,
|
<filename>bb.note</filename>, <filename>bb.plain</filename>,
|
||||||
and <filename>bb.debug</filename>.</para></listitem>
|
and <filename>bb.debug</filename>.</para></listitem>
|
||||||
<listitem><para><emphasis>Bash:</emphasis> For Bash functions you use the
|
<listitem><para><emphasis>Bash:</emphasis> For Bash functions, the same set
|
||||||
<filename>echo</filename> command and prepend a diagnostic string that includes
|
of loglevels exist and are accessed with a similar syntax:
|
||||||
the loglevel followed by a colon character</para></listitem>
|
<filename>bb.fatal</filename>, <filename>bb.error</filename>,
|
||||||
|
<filename>bb.warn</filename>, <filename>bb.note</filename>,
|
||||||
|
<filename>bb.plain</filename>, and <filename>bb.debug</filename>.</para></listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
For guidance on <filename>echo</filename> how logging is handled
|
||||||
|
in both Python and Bash recipes, see the
|
||||||
|
<filename>logging.bbclass</filename> file in the
|
||||||
|
<filename>meta/classes</filename> directory of the Yocto Project files.
|
||||||
|
</para>
|
||||||
|
|
||||||
<section id='logging-with-python'>
|
<section id='logging-with-python'>
|
||||||
<title>Logging With Python</title>
|
<title>Logging With Python</title>
|
||||||
<para>
|
<para>
|
||||||
|
@ -426,14 +434,8 @@
|
||||||
<para>
|
<para>
|
||||||
When creating recipes using Bash and inserting code that handles build
|
When creating recipes using Bash and inserting code that handles build
|
||||||
logs you have the same goals - informative with minimal console output.
|
logs you have the same goals - informative with minimal console output.
|
||||||
Use the <filename>echo</filename> command and prepend the diagnostic string
|
The syntax you use for recipes written in Bash is similar to that of
|
||||||
with the appropriate loglevel floowed by the colon character.
|
recipes written in Python described in the previous section.
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
For guidance on <filename>echo</filename> usage in Bash recipes, see the
|
|
||||||
<filename>logging.bbclass</filename> file in the
|
|
||||||
<filename>meta/classes</filename> directory of the Yocto Project files.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@ -441,21 +443,21 @@
|
||||||
The code logs the progress of the <filename>do_my_function</filename> function.
|
The code logs the progress of the <filename>do_my_function</filename> function.
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
do_my_function() {
|
do_my_function() {
|
||||||
echo "Running do_my_function()"
|
bbdebug 2 "Running do_my_function"
|
||||||
if [ exceptional_condition ]; then
|
if [ exceptional_condition ]; then
|
||||||
echo "NOTE: hit exceptional_condition"
|
bbnote "Hit exceptional_condition"
|
||||||
fi
|
fi
|
||||||
echo "DEBUG: got to point xyz"
|
bbdebug 2 "Got to point xyz"
|
||||||
if [ warning_trigger ]; then
|
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
|
fi
|
||||||
if [ recoverable_error ]; then
|
if [ recoverable_error ]; then
|
||||||
echo "ERROR: hit recoverable_error, correcting"
|
error "Hit recoverable_error, correcting"
|
||||||
fi
|
fi
|
||||||
if [ fatal_error ]; then
|
if [ fatal_error ]; then
|
||||||
echo "FATAL: fatal_error detected"
|
fatal "fatal_error detected"
|
||||||
fi
|
fi
|
||||||
echo "Completed do_my_function"
|
debug 2 "Completed do_my_function"
|
||||||
}
|
}
|
||||||
</literallayout>
|
</literallayout>
|
||||||
</para>
|
</para>
|
||||||
|
|
Loading…
Reference in New Issue