123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>2.3.7.1. Logging With Python</title>
- <link rel="stylesheet" type="text/css" href="../book.css">
- <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
- <link rel="home" href="index.html" title="The Yocto Project Reference Manual">
- <link rel="up" href="recipe-logging-mechanisms.html" title="2.3.7. Recipe Logging Mechanisms">
- <link rel="prev" href="recipe-logging-mechanisms.html" title="2.3.7. Recipe Logging Mechanisms">
- <link rel="next" href="logging-with-bash.html" title="2.3.7.2. Logging With Bash">
- </head>
- <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="section" title="2.3.7.1. Logging With Python">
- <div class="titlepage"><div><div><h4 class="title">
- <a name="logging-with-python"></a>2.3.7.1. Logging With Python</h4></div></div></div>
- <p>
- When creating recipes using Python and inserting code that handles build logs
- keep in mind the goal is to have informative logs while keeping the console as
- "silent" as possible.
- Also, if you want status messages in the log use the "debug" loglevel.
- </p>
- <p>
- Following is an example written in Python.
- The code handles logging for a function that determines the number of tasks
- needed to be run:
- </p>
- <pre class="literallayout">
- python do_listtasks() {
- bb.debug(2, "Starting to figure out the task list")
- if noteworthy_condition:
- bb.note("There are 47 tasks to run")
- bb.debug(2, "Got to point xyz")
- if warning_trigger:
- bb.warn("Detected warning_trigger, this might be a problem later.")
- if recoverable_error:
- bb.error("Hit recoverable_error, you really need to fix this!")
- if fatal_error:
- bb.fatal("fatal_error detected, unable to print the task list")
- bb.plain("The tasks present are abc")
- bb.debug(2, "Finished figuring out the tasklist")
- }
- </pre>
- <p>
- </p>
- </div></body>
- </html>
|