Team Ai
Apppublic

parthtamu/rag-code-assistant

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
logging.html2144 linesDownload Raw Back to docs
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4  <head>5    <meta charset="utf-8" />6    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="logging — Logging facility for Python" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/logging.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="Source code: Lib/logging/__init__.py Important: This page contains the API reference information. For tutorial information and discussion of more advanced topics, see Basic Tutorial, Advanced Tutor..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_logging_0b5a2ceb.png" />15<meta property="og:image:alt" content="Source code: Lib/logging/__init__.py Important: This page contains the API reference information. For tutorial information and discussion of more advanced topics, see Basic Tutorial, Advanced Tutor..." />16<meta name="description" content="Source code: Lib/logging/__init__.py Important: This page contains the API reference information. For tutorial information and discussion of more advanced topics, see Basic Tutorial, Advanced Tutor..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20    <title>logging — Logging facility for Python &#8212; Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21    22    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23    <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25    <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26    <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27    28    <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29    <script src="../_static/doctools.js?v=9bcbadda"></script>30    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31    <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32    33    <script src="../_static/sidebar.js"></script>34    35    <link rel="search" type="application/opensearchdescription+xml"36          title="Search within Python 3.15.0a6 documentation"37          href="../_static/opensearch.xml"/>38    <link rel="author" title="About these documents" href="../about.html" />39    <link rel="index" title="Index" href="../genindex.html" />40    <link rel="search" title="Search" href="../search.html" />41    <link rel="copyright" title="Copyright" href="../copyright.html" />42    <link rel="next" title="logging.config — Logging configuration" href="logging.config.html" />43    <link rel="prev" title="time — Time access and conversions" href="time.html" />44    45      46      <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47      48      <link rel="canonical" href="https://docs.python.org/3/library/logging.html">49      50    51 52    53    <style>54      @media only screen {55        table.full-width-table {56            width: 100%;57        }58      }59    </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61    <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62            <script type="text/javascript" src="../_static/copybutton.js"></script>63            <script type="text/javascript" src="../_static/menu.js"></script>64            <script type="text/javascript" src="../_static/search-focus.js"></script>65            <script type="text/javascript" src="../_static/themetoggle.js"></script> 66            <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67            <meta name="readthedocs-addons-api-version" content="1">68 69  </head>70<body>71<div class="mobile-nav">72    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74    <nav class="nav-content" role="navigation">75        <label for="menuToggler" class="toggler__label">76            <span></span>77        </label>78        <span class="nav-items-wrapper">79            <a href="https://www.python.org/" class="nav-logo">80                <img src="../_static/py.svg" alt="Python logo">81            </a>82            <span class="version_switcher_placeholder"></span>83            <form role="search" class="search" action="../search.html" method="get">84                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85                    <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>86                </svg>87                <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88                <input type="submit" value="Go">89            </form>90        </span>91    </nav>92    <div class="menu-wrapper">93        <nav class="menu" role="navigation" aria-label="main navigation">94            <div class="language_switcher_placeholder"></div>95            96<label class="theme-selector-label">97    Theme98    <select class="theme-selector" oninput="activateTheme(this.value)">99        <option value="auto" selected>Auto</option>100        <option value="light">Light</option>101        <option value="dark">Dark</option>102    </select>103</label>104  <div>105    <h3><a href="../contents.html">Table of Contents</a></h3>106    <ul>107<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging</span></code> — Logging facility for Python</a><ul>108<li><a class="reference internal" href="#logger-objects">Logger Objects</a></li>109<li><a class="reference internal" href="#logging-levels">Logging Levels</a></li>110<li><a class="reference internal" href="#handler-objects">Handler Objects</a></li>111<li><a class="reference internal" href="#formatter-objects">Formatter Objects</a></li>112<li><a class="reference internal" href="#filter-objects">Filter Objects</a></li>113<li><a class="reference internal" href="#logrecord-objects">LogRecord Objects</a></li>114<li><a class="reference internal" href="#logrecord-attributes">LogRecord attributes</a></li>115<li><a class="reference internal" href="#loggeradapter-objects">LoggerAdapter Objects</a></li>116<li><a class="reference internal" href="#thread-safety">Thread Safety</a></li>117<li><a class="reference internal" href="#module-level-functions">Module-Level Functions</a></li>118<li><a class="reference internal" href="#module-level-attributes">Module-Level Attributes</a></li>119<li><a class="reference internal" href="#integration-with-the-warnings-module">Integration with the warnings module</a></li>120</ul>121</li>122</ul>123 124  </div>125  <div>126    <h4>Previous topic</h4>127    <p class="topless"><a href="time.html"128                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code> — Time access and conversions</a></p>129  </div>130  <div>131    <h4>Next topic</h4>132    <p class="topless"><a href="logging.config.html"133                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging.config</span></code> — Logging configuration</a></p>134  </div>135  <script>136    document.addEventListener('DOMContentLoaded', () => {137        const title = document.querySelector('meta[property="og:title"]').content;138        const elements = document.querySelectorAll('.improvepage');139        const pageurl = window.location.href.split('?')[0];140        elements.forEach(element => {141            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));142            url.searchParams.set('pagetitle', title);143            url.searchParams.set('pageurl', pageurl);144            url.searchParams.set('pagesource', "library/logging.rst");145            element.href = url.toString();146        });147    });148  </script>149  <div role="note" aria-label="source link">150    <h3>This page</h3>151    <ul class="this-page-menu">152      <li><a href="../bugs.html">Report a bug</a></li>153      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>154      <li>155        <a href="https://github.com/python/cpython/blob/main/Doc/library/logging.rst?plain=1"156            rel="nofollow">Show source157        </a>158      </li>159      160    </ul>161  </div>162        </nav>163    </div>164</div>165 166  167    <div class="related" role="navigation" aria-label="Related">168      <h3>Navigation</h3>169      <ul>170        <li class="right" style="margin-right: 10px">171          <a href="../genindex.html" title="General Index"172             accesskey="I">index</a></li>173        <li class="right" >174          <a href="../py-modindex.html" title="Python Module Index"175             >modules</a> |</li>176        <li class="right" >177          <a href="logging.config.html" title="logging.config — Logging configuration"178             accesskey="N">next</a> |</li>179        <li class="right" >180          <a href="time.html" title="time — Time access and conversions"181             accesskey="P">previous</a> |</li>182 183          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>184          <li><a href="https://www.python.org/">Python</a> &#187;</li>185          <li class="switchers">186            <div class="language_switcher_placeholder"></div>187            <div class="version_switcher_placeholder"></div>188          </li>189          <li>190              191          </li>192    <li id="cpython-language-and-version">193      <a href="../index.html">3.15.0a6 Documentation</a> &#187;194    </li>195 196          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>197          <li class="nav-item nav-item-2"><a href="allos.html" accesskey="U">Generic Operating System Services</a> &#187;</li>198        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging</span></code> — Logging facility for Python</a></li>199                <li class="right">200                    201 202    <div class="inline-search" role="search">203        <form class="inline-search" action="../search.html" method="get">204          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">205          <input type="submit" value="Go">206        </form>207    </div>208                     |209                </li>210            <li class="right">211<label class="theme-selector-label">212    Theme213    <select class="theme-selector" oninput="activateTheme(this.value)">214        <option value="auto" selected>Auto</option>215        <option value="light">Light</option>216        <option value="dark">Dark</option>217    </select>218</label> |</li>219            220      </ul>221    </div>    222 223    <div class="document">224      <div class="documentwrapper">225        <div class="bodywrapper">226          <div class="body" role="main">227            228  <section id="module-logging">229<span id="logging-logging-facility-for-python"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging</span></code> — Logging facility for Python<a class="headerlink" href="#module-logging" title="Link to this heading">¶</a></h1>230<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/logging/__init__.py">Lib/logging/__init__.py</a></p>231<aside class="sidebar" id="index-0">232<p class="sidebar-title">Important</p>233<p>This page contains the API reference information. For tutorial234information and discussion of more advanced topics, see</p>235<ul class="simple">236<li><p><a class="reference internal" href="../howto/logging.html#logging-basic-tutorial"><span class="std std-ref">Basic Tutorial</span></a></p></li>237<li><p><a class="reference internal" href="../howto/logging.html#logging-advanced-tutorial"><span class="std std-ref">Advanced Tutorial</span></a></p></li>238<li><p><a class="reference internal" href="../howto/logging-cookbook.html#logging-cookbook"><span class="std std-ref">Logging Cookbook</span></a></p></li>239</ul>240</aside>241<hr class="docutils" />242<p>This module defines functions and classes which implement a flexible event243logging system for applications and libraries.</p>244<p>The key benefit of having the logging API provided by a standard library module245is that all Python modules can participate in logging, so your application log246can include your own messages integrated with messages from third-party247modules.</p>248<p>Here’s a simple example of idiomatic usage:</p>249<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># myapp.py</span>250<span class="kn">import</span><span class="w"> </span><span class="nn">logging</span>251<span class="kn">import</span><span class="w"> </span><span class="nn">mylib</span>252<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>253 254<span class="k">def</span><span class="w"> </span><span class="nf">main</span><span class="p">():</span>255    <span class="n">logging</span><span class="o">.</span><span class="n">basicConfig</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="s1">&#39;myapp.log&#39;</span><span class="p">,</span> <span class="n">level</span><span class="o">=</span><span class="n">logging</span><span class="o">.</span><span class="n">INFO</span><span class="p">)</span>256    <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;Started&#39;</span><span class="p">)</span>257    <span class="n">mylib</span><span class="o">.</span><span class="n">do_something</span><span class="p">()</span>258    <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;Finished&#39;</span><span class="p">)</span>259 260<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>261    <span class="n">main</span><span class="p">()</span>262</pre></div>263</div>264<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># mylib.py</span>265<span class="kn">import</span><span class="w"> </span><span class="nn">logging</span>266<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>267 268<span class="k">def</span><span class="w"> </span><span class="nf">do_something</span><span class="p">():</span>269    <span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;Doing something&#39;</span><span class="p">)</span>270</pre></div>271</div>272<p>If you run <em>myapp.py</em>, you should see this in <em>myapp.log</em>:</p>273<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>INFO:__main__:Started274INFO:mylib:Doing something275INFO:__main__:Finished276</pre></div>277</div>278<p>The key feature of this idiomatic usage is that the majority of code is simply279creating a module level logger with <code class="docutils literal notranslate"><span class="pre">getLogger(__name__)</span></code>, and using that280logger to do any needed logging. This is concise, while allowing downstream281code fine-grained control if needed. Logged messages to the module-level logger282get forwarded to handlers of loggers in higher-level modules, all the way up to283the highest-level logger known as the root logger; this approach is known as284hierarchical logging.</p>285<p>For logging to be useful, it needs to be configured: setting the levels and286destinations for each logger, potentially changing how specific modules log,287often based on command-line arguments or application configuration. In most288cases, like the one above, only the root logger needs to be so configured, since289all the lower level loggers at module level eventually forward their messages to290its handlers.  <a class="reference internal" href="#logging.basicConfig" title="logging.basicConfig"><code class="xref py py-func docutils literal notranslate"><span class="pre">basicConfig()</span></code></a> provides a quick way to configure291the root logger that handles many use cases.</p>292<p>The module provides a lot of functionality and flexibility.  If you are293unfamiliar with logging, the best way to get to grips with it is to view the294tutorials (<strong>see the links above and on the right</strong>).</p>295<p>The basic classes defined by the module, together with their attributes and296methods, are listed in the sections below.</p>297<ul class="simple">298<li><p>Loggers expose the interface that application code directly uses.</p></li>299<li><p>Handlers send the log records (created by loggers) to the appropriate300destination.</p></li>301<li><p>Filters provide a finer grained facility for determining which log records302to output.</p></li>303<li><p>Formatters specify the layout of log records in the final output.</p></li>304</ul>305<section id="logger-objects">306<span id="logger"></span><h2>Logger Objects<a class="headerlink" href="#logger-objects" title="Link to this heading">¶</a></h2>307<p>Loggers have the following attributes and methods.  Note that Loggers should308<em>NEVER</em> be instantiated directly, but always through the module-level function309<code class="docutils literal notranslate"><span class="pre">logging.getLogger(name)</span></code>.  Multiple calls to <a class="reference internal" href="#logging.getLogger" title="logging.getLogger"><code class="xref py py-func docutils literal notranslate"><span class="pre">getLogger()</span></code></a> with the same310name will always return a reference to the same Logger object.</p>311<p>The <code class="docutils literal notranslate"><span class="pre">name</span></code> is potentially a period-separated hierarchical value, like312<code class="docutils literal notranslate"><span class="pre">foo.bar.baz</span></code> (though it could also be just plain <code class="docutils literal notranslate"><span class="pre">foo</span></code>, for example).313Loggers that are further down in the hierarchical list are children of loggers314higher up in the list.  For example, given a logger with a name of <code class="docutils literal notranslate"><span class="pre">foo</span></code>,315loggers with names of <code class="docutils literal notranslate"><span class="pre">foo.bar</span></code>, <code class="docutils literal notranslate"><span class="pre">foo.bar.baz</span></code>, and <code class="docutils literal notranslate"><span class="pre">foo.bam</span></code> are all316descendants of <code class="docutils literal notranslate"><span class="pre">foo</span></code>.  In addition, all loggers are descendants of the root317logger. The logger name hierarchy is analogous to the Python package hierarchy,318and identical to it if you organise your loggers on a per-module basis using319the recommended construction <code class="docutils literal notranslate"><span class="pre">logging.getLogger(__name__)</span></code>.  That’s because320in a module, <code class="docutils literal notranslate"><span class="pre">__name__</span></code> is the module’s name in the Python package namespace.</p>321<dl class="py class">322<dt class="sig sig-object py" id="logging.Logger">323<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">Logger</span></span><a class="headerlink" href="#logging.Logger" title="Link to this definition">¶</a></dt>324<dd><dl class="py attribute">325<dt class="sig sig-object py" id="logging.Logger.name">326<span class="sig-name descname"><span class="pre">name</span></span><a class="headerlink" href="#logging.Logger.name" title="Link to this definition">¶</a></dt>327<dd><p>This is the logger’s name, and is the value that was passed to <a class="reference internal" href="#logging.getLogger" title="logging.getLogger"><code class="xref py py-func docutils literal notranslate"><span class="pre">getLogger()</span></code></a>328to obtain the logger.</p>329<div class="admonition note">330<p class="admonition-title">Note</p>331<p>This attribute should be treated as read-only.</p>332</div>333</dd></dl>334 335<dl class="py attribute">336<dt class="sig sig-object py" id="logging.Logger.level">337<span class="sig-name descname"><span class="pre">level</span></span><a class="headerlink" href="#logging.Logger.level" title="Link to this definition">¶</a></dt>338<dd><p>The threshold of this logger, as set by the <a class="reference internal" href="#logging.Logger.setLevel" title="logging.Logger.setLevel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLevel()</span></code></a> method.</p>339<div class="admonition note">340<p class="admonition-title">Note</p>341<p>Do not set this attribute directly - always use <a class="reference internal" href="#logging.Logger.setLevel" title="logging.Logger.setLevel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLevel()</span></code></a>,342which has checks for the level passed to it.</p>343</div>344</dd></dl>345 346<dl class="py attribute">347<dt class="sig sig-object py" id="logging.Logger.parent">348<span class="sig-name descname"><span class="pre">parent</span></span><a class="headerlink" href="#logging.Logger.parent" title="Link to this definition">¶</a></dt>349<dd><p>The parent logger of this logger. It may change based on later instantiation350of loggers which are higher up in the namespace hierarchy.</p>351<div class="admonition note">352<p class="admonition-title">Note</p>353<p>This value should be treated as read-only.</p>354</div>355</dd></dl>356 357<dl class="py attribute">358<dt class="sig sig-object py" id="logging.Logger.propagate">359<span class="sig-name descname"><span class="pre">propagate</span></span><a class="headerlink" href="#logging.Logger.propagate" title="Link to this definition">¶</a></dt>360<dd><p>If this attribute evaluates to true, events logged to this logger will be361passed to the handlers of higher level (ancestor) loggers, in addition to362any handlers attached to this logger. Messages are passed directly to the363ancestor loggers’ handlers - neither the level nor filters of the ancestor364loggers in question are considered.</p>365<p>If this evaluates to false, logging messages are not passed to the handlers366of ancestor loggers.</p>367<p>Spelling it out with an example: If the propagate attribute of the logger named368<code class="docutils literal notranslate"><span class="pre">A.B.C</span></code> evaluates to true, any event logged to <code class="docutils literal notranslate"><span class="pre">A.B.C</span></code> via a method call such as369<code class="docutils literal notranslate"><span class="pre">logging.getLogger('A.B.C').error(...)</span></code> will [subject to passing that logger’s370level and filter settings] be passed in turn to any handlers attached to loggers371named <code class="docutils literal notranslate"><span class="pre">A.B</span></code>, <code class="docutils literal notranslate"><span class="pre">A</span></code> and the root logger, after first being passed to any handlers372attached to <code class="docutils literal notranslate"><span class="pre">A.B.C</span></code>. If any logger in the chain <code class="docutils literal notranslate"><span class="pre">A.B.C</span></code>, <code class="docutils literal notranslate"><span class="pre">A.B</span></code>, <code class="docutils literal notranslate"><span class="pre">A</span></code> has its373<code class="docutils literal notranslate"><span class="pre">propagate</span></code> attribute set to false, then that is the last logger whose handlers374are offered the event to handle, and propagation stops at that point.</p>375<p>The constructor sets this attribute to <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p>376<div class="admonition note">377<p class="admonition-title">Note</p>378<p>If you attach a handler to a logger <em>and</em> one or more of its379ancestors, it may emit the same record multiple times. In general, you380should not need to attach a handler to more than one logger - if you just381attach it to the appropriate logger which is highest in the logger382hierarchy, then it will see all events logged by all descendant loggers,383provided that their propagate setting is left set to <code class="docutils literal notranslate"><span class="pre">True</span></code>. A common384scenario is to attach handlers only to the root logger, and to let385propagation take care of the rest.</p>386</div>387</dd></dl>388 389<dl class="py attribute">390<dt class="sig sig-object py" id="logging.Logger.handlers">391<span class="sig-name descname"><span class="pre">handlers</span></span><a class="headerlink" href="#logging.Logger.handlers" title="Link to this definition">¶</a></dt>392<dd><p>The list of handlers directly attached to this logger instance.</p>393<div class="admonition note">394<p class="admonition-title">Note</p>395<p>This attribute should be treated as read-only; it is normally changed via396the <a class="reference internal" href="#logging.Logger.addHandler" title="logging.Logger.addHandler"><code class="xref py py-meth docutils literal notranslate"><span class="pre">addHandler()</span></code></a> and <a class="reference internal" href="#logging.Logger.removeHandler" title="logging.Logger.removeHandler"><code class="xref py py-meth docutils literal notranslate"><span class="pre">removeHandler()</span></code></a> methods, which use locks to ensure397thread-safe operation.</p>398</div>399</dd></dl>400 401<dl class="py attribute">402<dt class="sig sig-object py" id="logging.Logger.disabled">403<span class="sig-name descname"><span class="pre">disabled</span></span><a class="headerlink" href="#logging.Logger.disabled" title="Link to this definition">¶</a></dt>404<dd><p>This attribute disables handling of any events. It is set to <code class="docutils literal notranslate"><span class="pre">False</span></code> in the405initializer, and only changed by logging configuration code.</p>406<div class="admonition note">407<p class="admonition-title">Note</p>408<p>This attribute should be treated as read-only.</p>409</div>410</dd></dl>411 412<dl class="py method">413<dt class="sig sig-object py" id="logging.Logger.setLevel">414<span class="sig-name descname"><span class="pre">setLevel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">level</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.setLevel" title="Link to this definition">¶</a></dt>415<dd><p>Sets the threshold for this logger to <em>level</em>. Logging messages which are less416severe than <em>level</em> will be ignored; logging messages which have severity <em>level</em>417or higher will be emitted by whichever handler or handlers service this logger,418unless a handler’s level has been set to a higher severity level than <em>level</em>.</p>419<p>When a logger is created, the level is set to <a class="reference internal" href="#logging.NOTSET" title="logging.NOTSET"><code class="xref py py-const docutils literal notranslate"><span class="pre">NOTSET</span></code></a> (which causes420all messages to be processed when the logger is the root logger, or delegation421to the parent when the logger is a non-root logger). Note that the root logger422is created with level <a class="reference internal" href="#logging.WARNING" title="logging.WARNING"><code class="xref py py-const docutils literal notranslate"><span class="pre">WARNING</span></code></a>.</p>423<p>The term ‘delegation to the parent’ means that if a logger has a level of424NOTSET, its chain of ancestor loggers is traversed until either an ancestor with425a level other than NOTSET is found, or the root is reached.</p>426<p>If an ancestor is found with a level other than NOTSET, then that ancestor’s427level is treated as the effective level of the logger where the ancestor search428began, and is used to determine how a logging event is handled.</p>429<p>If the root is reached, and it has a level of NOTSET, then all messages will be430processed. Otherwise, the root’s level will be used as the effective level.</p>431<p>See <a class="reference internal" href="#levels"><span class="std std-ref">Logging Levels</span></a> for a list of levels.</p>432<div class="versionchanged">433<p><span class="versionmodified changed">Changed in version 3.2: </span>The <em>level</em> parameter now accepts a string representation of the434level such as ‘INFO’ as an alternative to the integer constants435such as <a class="reference internal" href="#logging.INFO" title="logging.INFO"><code class="xref py py-const docutils literal notranslate"><span class="pre">INFO</span></code></a>. Note, however, that levels are internally stored436as integers, and methods such as e.g. <a class="reference internal" href="#logging.Logger.getEffectiveLevel" title="logging.Logger.getEffectiveLevel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getEffectiveLevel()</span></code></a> and437<a class="reference internal" href="#logging.Logger.isEnabledFor" title="logging.Logger.isEnabledFor"><code class="xref py py-meth docutils literal notranslate"><span class="pre">isEnabledFor()</span></code></a> will return/expect to be passed integers.</p>438</div>439</dd></dl>440 441<dl class="py method">442<dt class="sig sig-object py" id="logging.Logger.isEnabledFor">443<span class="sig-name descname"><span class="pre">isEnabledFor</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">level</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.isEnabledFor" title="Link to this definition">¶</a></dt>444<dd><p>Indicates if a message of severity <em>level</em> would be processed by this logger.445This method checks first the module-level level set by446<code class="docutils literal notranslate"><span class="pre">logging.disable(level)</span></code> and then the logger’s effective level as determined447by <a class="reference internal" href="#logging.Logger.getEffectiveLevel" title="logging.Logger.getEffectiveLevel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getEffectiveLevel()</span></code></a>.</p>448</dd></dl>449 450<dl class="py method">451<dt class="sig sig-object py" id="logging.Logger.getEffectiveLevel">452<span class="sig-name descname"><span class="pre">getEffectiveLevel</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.getEffectiveLevel" title="Link to this definition">¶</a></dt>453<dd><p>Indicates the effective level for this logger. If a value other than454<a class="reference internal" href="#logging.NOTSET" title="logging.NOTSET"><code class="xref py py-const docutils literal notranslate"><span class="pre">NOTSET</span></code></a> has been set using <a class="reference internal" href="#logging.Logger.setLevel" title="logging.Logger.setLevel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setLevel()</span></code></a>, it is returned. Otherwise,455the hierarchy is traversed towards the root until a value other than456<code class="xref py py-const docutils literal notranslate"><span class="pre">NOTSET</span></code> is found, and that value is returned. The value returned is457an integer, typically one of <a class="reference internal" href="#logging.DEBUG" title="logging.DEBUG"><code class="xref py py-const docutils literal notranslate"><span class="pre">logging.DEBUG</span></code></a>, <a class="reference internal" href="#logging.INFO" title="logging.INFO"><code class="xref py py-const docutils literal notranslate"><span class="pre">logging.INFO</span></code></a>458etc.</p>459</dd></dl>460 461<dl class="py method">462<dt class="sig sig-object py" id="logging.Logger.getChild">463<span class="sig-name descname"><span class="pre">getChild</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">suffix</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.getChild" title="Link to this definition">¶</a></dt>464<dd><p>Returns a logger which is a descendant to this logger, as determined by the suffix.465Thus, <code class="docutils literal notranslate"><span class="pre">logging.getLogger('abc').getChild('def.ghi')</span></code> would return the same466logger as would be returned by <code class="docutils literal notranslate"><span class="pre">logging.getLogger('abc.def.ghi')</span></code>. This is a467convenience method, useful when the parent logger is named using e.g. <code class="docutils literal notranslate"><span class="pre">__name__</span></code>468rather than a literal string.</p>469<div class="versionadded">470<p><span class="versionmodified added">Added in version 3.2.</span></p>471</div>472</dd></dl>473 474<dl class="py method">475<dt class="sig sig-object py" id="logging.Logger.getChildren">476<span class="sig-name descname"><span class="pre">getChildren</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.getChildren" title="Link to this definition">¶</a></dt>477<dd><p>Returns a set of loggers which are immediate children of this logger. So for478example <code class="docutils literal notranslate"><span class="pre">logging.getLogger().getChildren()</span></code> might return a set containing479loggers named <code class="docutils literal notranslate"><span class="pre">foo</span></code> and <code class="docutils literal notranslate"><span class="pre">bar</span></code>, but a logger named <code class="docutils literal notranslate"><span class="pre">foo.bar</span></code> wouldn’t be480included in the set. Likewise, <code class="docutils literal notranslate"><span class="pre">logging.getLogger('foo').getChildren()</span></code> might481return a set including a logger named <code class="docutils literal notranslate"><span class="pre">foo.bar</span></code>, but it wouldn’t include one482named <code class="docutils literal notranslate"><span class="pre">foo.bar.baz</span></code>.</p>483<div class="versionadded">484<p><span class="versionmodified added">Added in version 3.12.</span></p>485</div>486</dd></dl>487 488<dl class="py method">489<dt class="sig sig-object py" id="logging.Logger.debug">490<span class="sig-name descname"><span class="pre">debug</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.debug" title="Link to this definition">¶</a></dt>491<dd><p>Logs a message with level <a class="reference internal" href="#logging.DEBUG" title="logging.DEBUG"><code class="xref py py-const docutils literal notranslate"><span class="pre">DEBUG</span></code></a> on this logger. The <em>msg</em> is the492message format string, and the <em>args</em> are the arguments which are merged into493<em>msg</em> using the string formatting operator. (Note that this means that you can494use keywords in the format string, together with a single dictionary argument.)495No % formatting operation is performed on <em>msg</em> when no <em>args</em> are supplied.</p>496<p>There are four keyword arguments in <em>kwargs</em> which are inspected:497<em>exc_info</em>, <em>stack_info</em>, <em>stacklevel</em> and <em>extra</em>.</p>498<p>If <em>exc_info</em> does not evaluate as false, it causes exception information to be499added to the logging message. If an exception tuple (in the format returned by500<a class="reference internal" href="sys.html#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exc_info()</span></code></a>) or an exception instance is provided, it is used;501otherwise, <code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exc_info()</span></code> is called to get the exception information.</p>502<p>The second optional keyword argument is <em>stack_info</em>, which defaults to503<code class="docutils literal notranslate"><span class="pre">False</span></code>. If true, stack information is added to the logging504message, including the actual logging call. Note that this is not the same505stack information as that displayed through specifying <em>exc_info</em>: The506former is stack frames from the bottom of the stack up to the logging call507in the current thread, whereas the latter is information about stack frames508which have been unwound, following an exception, while searching for509exception handlers.</p>510<p>You can specify <em>stack_info</em> independently of <em>exc_info</em>, e.g. to just show511how you got to a certain point in your code, even when no exceptions were512raised. The stack frames are printed following a header line which says:</p>513<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Stack (most recent call last):514</pre></div>515</div>516<p>This mimics the <code class="docutils literal notranslate"><span class="pre">Traceback</span> <span class="pre">(most</span> <span class="pre">recent</span> <span class="pre">call</span> <span class="pre">last):</span></code> which is used when517displaying exception frames.</p>518<p>The third optional keyword argument is <em>stacklevel</em>, which defaults to <code class="docutils literal notranslate"><span class="pre">1</span></code>.519If greater than 1, the corresponding number of stack frames are skipped520when computing the line number and function name set in the <a class="reference internal" href="#logging.LogRecord" title="logging.LogRecord"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code></a>521created for the logging event. This can be used in logging helpers so that522the function name, filename and line number recorded are not the information523for the helper function/method, but rather its caller. The name of this524parameter mirrors the equivalent one in the <a class="reference internal" href="warnings.html#module-warnings" title="warnings: Issue warning messages and control their disposition."><code class="xref py py-mod docutils literal notranslate"><span class="pre">warnings</span></code></a> module.</p>525<p>The fourth keyword argument is <em>extra</em> which can be used to pass a526dictionary which is used to populate the <a class="reference internal" href="../reference/datamodel.html#object.__dict__" title="object.__dict__"><code class="xref py py-attr docutils literal notranslate"><span class="pre">__dict__</span></code></a> of the527<a class="reference internal" href="#logging.LogRecord" title="logging.LogRecord"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code></a>528created for the logging event with user-defined attributes. These custom529attributes can then be used as you like. For example, they could be530incorporated into logged messages. For example:</p>531<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">FORMAT</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%(asctime)s</span><span class="s1"> </span><span class="si">%(clientip)-15s</span><span class="s1"> </span><span class="si">%(user)-8s</span><span class="s1"> </span><span class="si">%(message)s</span><span class="s1">&#39;</span>532<span class="n">logging</span><span class="o">.</span><span class="n">basicConfig</span><span class="p">(</span><span class="nb">format</span><span class="o">=</span><span class="n">FORMAT</span><span class="p">)</span>533<span class="n">d</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;clientip&#39;</span><span class="p">:</span> <span class="s1">&#39;192.168.0.1&#39;</span><span class="p">,</span> <span class="s1">&#39;user&#39;</span><span class="p">:</span> <span class="s1">&#39;fbloggs&#39;</span><span class="p">}</span>534<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s1">&#39;tcpserver&#39;</span><span class="p">)</span>535<span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s1">&#39;Protocol problem: </span><span class="si">%s</span><span class="s1">&#39;</span><span class="p">,</span> <span class="s1">&#39;connection reset&#39;</span><span class="p">,</span> <span class="n">extra</span><span class="o">=</span><span class="n">d</span><span class="p">)</span>536</pre></div>537</div>538<p>would print something like</p>539<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>2006-02-08 22:20:02,165 192.168.0.1 fbloggs  Protocol problem: connection reset540</pre></div>541</div>542<p>The keys in the dictionary passed in <em>extra</em> should not clash with the keys used543by the logging system. (See the section on <a class="reference internal" href="#logrecord-attributes"><span class="std std-ref">LogRecord attributes</span></a> for more544information on which keys are used by the logging system.)</p>545<p>If you choose to use these attributes in logged messages, you need to exercise546some care. In the above example, for instance, the <a class="reference internal" href="#logging.Formatter" title="logging.Formatter"><code class="xref py py-class docutils literal notranslate"><span class="pre">Formatter</span></code></a> has been547set up with a format string which expects ‘clientip’ and ‘user’ in the attribute548dictionary of the <a class="reference internal" href="#logging.LogRecord" title="logging.LogRecord"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code></a>. If these are missing, the message will549not be logged because a string formatting exception will occur. So in this case,550you always need to pass the <em>extra</em> dictionary with these keys.</p>551<p>While this might be annoying, this feature is intended for use in specialized552circumstances, such as multi-threaded servers where the same code executes in553many contexts, and interesting conditions which arise are dependent on this554context (such as remote client IP address and authenticated user name, in the555above example). In such circumstances, it is likely that specialized556<a class="reference internal" href="#logging.Formatter" title="logging.Formatter"><code class="xref py py-class docutils literal notranslate"><span class="pre">Formatter</span></code></a>s would be used with particular <a class="reference internal" href="#logging.Handler" title="logging.Handler"><code class="xref py py-class docutils literal notranslate"><span class="pre">Handler</span></code></a>s.</p>557<p>If no handler is attached to this logger (or any of its ancestors,558taking into account the relevant <a class="reference internal" href="#logging.Logger.propagate" title="logging.Logger.propagate"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Logger.propagate</span></code></a> attributes),559the message will be sent to the handler set on <a class="reference internal" href="#logging.lastResort" title="logging.lastResort"><code class="xref py py-data docutils literal notranslate"><span class="pre">lastResort</span></code></a>.</p>560<div class="versionchanged">561<p><span class="versionmodified changed">Changed in version 3.2: </span>The <em>stack_info</em> parameter was added.</p>562</div>563<div class="versionchanged">564<p><span class="versionmodified changed">Changed in version 3.5: </span>The <em>exc_info</em> parameter can now accept exception instances.</p>565</div>566<div class="versionchanged">567<p><span class="versionmodified changed">Changed in version 3.8: </span>The <em>stacklevel</em> parameter was added.</p>568</div>569</dd></dl>570 571<dl class="py method">572<dt class="sig sig-object py" id="logging.Logger.info">573<span class="sig-name descname"><span class="pre">info</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.info" title="Link to this definition">¶</a></dt>574<dd><p>Logs a message with level <a class="reference internal" href="#logging.INFO" title="logging.INFO"><code class="xref py py-const docutils literal notranslate"><span class="pre">INFO</span></code></a> on this logger. The arguments are575interpreted as for <a class="reference internal" href="#logging.debug" title="logging.debug"><code class="xref py py-meth docutils literal notranslate"><span class="pre">debug()</span></code></a>.</p>576</dd></dl>577 578<dl class="py method">579<dt class="sig sig-object py" id="logging.Logger.warning">580<span class="sig-name descname"><span class="pre">warning</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.warning" title="Link to this definition">¶</a></dt>581<dd><p>Logs a message with level <a class="reference internal" href="#logging.WARNING" title="logging.WARNING"><code class="xref py py-const docutils literal notranslate"><span class="pre">WARNING</span></code></a> on this logger. The arguments are582interpreted as for <a class="reference internal" href="#logging.debug" title="logging.debug"><code class="xref py py-meth docutils literal notranslate"><span class="pre">debug()</span></code></a>.</p>583<div class="admonition note">584<p class="admonition-title">Note</p>585<p>There is an obsolete method <code class="docutils literal notranslate"><span class="pre">warn</span></code> which is functionally586identical to <code class="docutils literal notranslate"><span class="pre">warning</span></code>. As <code class="docutils literal notranslate"><span class="pre">warn</span></code> is deprecated, please do not use587it - use <code class="docutils literal notranslate"><span class="pre">warning</span></code> instead.</p>588</div>589</dd></dl>590 591<dl class="py method">592<dt class="sig sig-object py" id="logging.Logger.error">593<span class="sig-name descname"><span class="pre">error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.error" title="Link to this definition">¶</a></dt>594<dd><p>Logs a message with level <a class="reference internal" href="#logging.ERROR" title="logging.ERROR"><code class="xref py py-const docutils literal notranslate"><span class="pre">ERROR</span></code></a> on this logger. The arguments are595interpreted as for <a class="reference internal" href="#logging.debug" title="logging.debug"><code class="xref py py-meth docutils literal notranslate"><span class="pre">debug()</span></code></a>.</p>596</dd></dl>597 598<dl class="py method">599<dt class="sig sig-object py" id="logging.Logger.critical">600<span class="sig-name descname"><span class="pre">critical</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.critical" title="Link to this definition">¶</a></dt>601<dd><p>Logs a message with level <a class="reference internal" href="#logging.CRITICAL" title="logging.CRITICAL"><code class="xref py py-const docutils literal notranslate"><span class="pre">CRITICAL</span></code></a> on this logger. The arguments are602interpreted as for <a class="reference internal" href="#logging.debug" title="logging.debug"><code class="xref py py-meth docutils literal notranslate"><span class="pre">debug()</span></code></a>.</p>603</dd></dl>604 605<dl class="py method">606<dt class="sig sig-object py" id="logging.Logger.log">607<span class="sig-name descname"><span class="pre">log</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">level</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.log" title="Link to this definition">¶</a></dt>608<dd><p>Logs a message with integer level <em>level</em> on this logger. The other arguments are609interpreted as for <a class="reference internal" href="#logging.debug" title="logging.debug"><code class="xref py py-meth docutils literal notranslate"><span class="pre">debug()</span></code></a>.</p>610</dd></dl>611 612<dl class="py method">613<dt class="sig sig-object py" id="logging.Logger.exception">614<span class="sig-name descname"><span class="pre">exception</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.exception" title="Link to this definition">¶</a></dt>615<dd><p>Logs a message with level <a class="reference internal" href="#logging.ERROR" title="logging.ERROR"><code class="xref py py-const docutils literal notranslate"><span class="pre">ERROR</span></code></a> on this logger. The arguments are616interpreted as for <a class="reference internal" href="#logging.debug" title="logging.debug"><code class="xref py py-meth docutils literal notranslate"><span class="pre">debug()</span></code></a>. Exception info is added to the logging617message. This method should only be called from an exception handler.</p>618</dd></dl>619 620<dl class="py method">621<dt class="sig sig-object py" id="logging.Logger.addFilter">622<span class="sig-name descname"><span class="pre">addFilter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filter</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.addFilter" title="Link to this definition">¶</a></dt>623<dd><p>Adds the specified filter <em>filter</em> to this logger.</p>624</dd></dl>625 626<dl class="py method">627<dt class="sig sig-object py" id="logging.Logger.removeFilter">628<span class="sig-name descname"><span class="pre">removeFilter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filter</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.removeFilter" title="Link to this definition">¶</a></dt>629<dd><p>Removes the specified filter <em>filter</em> from this logger.</p>630</dd></dl>631 632<dl class="py method">633<dt class="sig sig-object py" id="logging.Logger.filter">634<span class="sig-name descname"><span class="pre">filter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.filter" title="Link to this definition">¶</a></dt>635<dd><p>Apply this logger’s filters to the record and return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the636record is to be processed. The filters are consulted in turn, until one of637them returns a false value. If none of them return a false value, the record638will be processed (passed to handlers). If one returns a false value, no639further processing of the record occurs.</p>640</dd></dl>641 642<dl class="py method">643<dt class="sig sig-object py" id="logging.Logger.addHandler">644<span class="sig-name descname"><span class="pre">addHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">hdlr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.addHandler" title="Link to this definition">¶</a></dt>645<dd><p>Adds the specified handler <em>hdlr</em> to this logger.</p>646</dd></dl>647 648<dl class="py method">649<dt class="sig sig-object py" id="logging.Logger.removeHandler">650<span class="sig-name descname"><span class="pre">removeHandler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">hdlr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.removeHandler" title="Link to this definition">¶</a></dt>651<dd><p>Removes the specified handler <em>hdlr</em> from this logger.</p>652</dd></dl>653 654<dl class="py method">655<dt class="sig sig-object py" id="logging.Logger.findCaller">656<span class="sig-name descname"><span class="pre">findCaller</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack_info</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stacklevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.findCaller" title="Link to this definition">¶</a></dt>657<dd><p>Finds the caller’s source filename and line number. Returns the filename, line658number, function name and stack information as a 4-element tuple. The stack659information is returned as <code class="docutils literal notranslate"><span class="pre">None</span></code> unless <em>stack_info</em> is <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p>660<p>The <em>stacklevel</em> parameter is passed from code calling the <a class="reference internal" href="#logging.debug" title="logging.debug"><code class="xref py py-meth docutils literal notranslate"><span class="pre">debug()</span></code></a>661and other APIs. If greater than 1, the excess is used to skip stack frames662before determining the values to be returned. This will generally be useful663when calling logging APIs from helper/wrapper code, so that the information664in the event log refers not to the helper/wrapper code, but to the code that665calls it.</p>666</dd></dl>667 668<dl class="py method">669<dt class="sig sig-object py" id="logging.Logger.handle">670<span class="sig-name descname"><span class="pre">handle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.handle" title="Link to this definition">¶</a></dt>671<dd><p>Handles a record by passing it to all handlers associated with this logger and672its ancestors (until a false value of <em>propagate</em> is found). This method is used673for unpickled records received from a socket, as well as those created locally.674Logger-level filtering is applied using <a class="reference internal" href="#logging.Logger.filter" title="logging.Logger.filter"><code class="xref py py-meth docutils literal notranslate"><span class="pre">filter()</span></code></a>.</p>675</dd></dl>676 677<dl class="py method">678<dt class="sig sig-object py" id="logging.Logger.makeRecord">679<span class="sig-name descname"><span class="pre">makeRecord</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">level</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fn</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lno</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exc_info</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extra</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sinfo</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.makeRecord" title="Link to this definition">¶</a></dt>680<dd><p>This is a factory method which can be overridden in subclasses to create681specialized <a class="reference internal" href="#logging.LogRecord" title="logging.LogRecord"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code></a> instances.</p>682</dd></dl>683 684<dl class="py method">685<dt class="sig sig-object py" id="logging.Logger.hasHandlers">686<span class="sig-name descname"><span class="pre">hasHandlers</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#logging.Logger.hasHandlers" title="Link to this definition">¶</a></dt>687<dd><p>Checks to see if this logger has any handlers configured. This is done by688looking for handlers in this logger and its parents in the logger hierarchy.689Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if a handler was found, else <code class="docutils literal notranslate"><span class="pre">False</span></code>. The method stops searching690up the hierarchy whenever a logger with the ‘propagate’ attribute set to691false is found - that will be the last logger which is checked for the692existence of handlers.</p>693<div class="versionadded">694<p><span class="versionmodified added">Added in version 3.2.</span></p>695</div>696</dd></dl>697 698<div class="versionchanged">699<p><span class="versionmodified changed">Changed in version 3.7: </span>Loggers can now be pickled and unpickled.</p>700</div>701</dd></dl>702 703</section>704<section id="logging-levels">705<span id="levels"></span><h2>Logging Levels<a class="headerlink" href="#logging-levels" title="Link to this heading">¶</a></h2>706<p>The numeric values of logging levels are given in the following table. These are707primarily of interest if you want to define your own levels, and need them to708have specific values relative to the predefined levels. If you define a level709with the same numeric value, it overwrites the predefined value; the predefined710name is lost.</p>711<table class="docutils align-default">712<thead>713<tr class="row-odd"><th class="head"><p>Level</p></th>714<th class="head"><p>Numeric value</p></th>715<th class="head"><p>What it means / When to use it</p></th>716</tr>717</thead>718<tbody>719<tr class="row-even"><td><dl class="py data">720<dt class="sig sig-object py" id="logging.NOTSET">721<span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">NOTSET</span></span><a class="headerlink" href="#logging.NOTSET" title="Link to this definition">¶</a></dt>722<dd></dd></dl>723 724</td>725<td><p>0</p></td>726<td><p>When set on a logger, indicates that727ancestor loggers are to be consulted728to determine the effective level.729If that still resolves to730<code class="xref py py-const docutils literal notranslate"><span class="pre">NOTSET</span></code>, then all events731are logged. When set on a handler,732all events are handled.</p></td>733</tr>734<tr class="row-odd"><td><dl class="py data">735<dt class="sig sig-object py" id="logging.DEBUG">736<span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">DEBUG</span></span><a class="headerlink" href="#logging.DEBUG" title="Link to this definition">¶</a></dt>737<dd></dd></dl>738 739</td>740<td><p>10</p></td>741<td><p>Detailed information, typically only742of interest to a developer trying to743diagnose a problem.</p></td>744</tr>745<tr class="row-even"><td><dl class="py data">746<dt class="sig sig-object py" id="logging.INFO">747<span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">INFO</span></span><a class="headerlink" href="#logging.INFO" title="Link to this definition">¶</a></dt>748<dd></dd></dl>749 750</td>751<td><p>20</p></td>752<td><p>Confirmation that things are working753as expected.</p></td>754</tr>755<tr class="row-odd"><td><dl class="py data">756<dt class="sig sig-object py" id="logging.WARNING">757<span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">WARNING</span></span><a class="headerlink" href="#logging.WARNING" title="Link to this definition">¶</a></dt>758<dd></dd></dl>759 760</td>761<td><p>30</p></td>762<td><p>An indication that something763unexpected happened, or that a764problem might occur in the near765future (e.g. ‘disk space low’). The766software is still working as767expected.</p></td>768</tr>769<tr class="row-even"><td><dl class="py data">770<dt class="sig sig-object py" id="logging.ERROR">771<span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">ERROR</span></span><a class="headerlink" href="#logging.ERROR" title="Link to this definition">¶</a></dt>772<dd></dd></dl>773 774</td>775<td><p>40</p></td>776<td><p>Due to a more serious problem, the777software has not been able to778perform some function.</p></td>779</tr>780<tr class="row-odd"><td><dl class="py data">781<dt class="sig sig-object py" id="logging.CRITICAL">782<span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">CRITICAL</span></span><a class="headerlink" href="#logging.CRITICAL" title="Link to this definition">¶</a></dt>783<dd></dd></dl>784 785</td>786<td><p>50</p></td>787<td><p>A serious error, indicating that the788program itself may be unable to789continue running.</p></td>790</tr>791</tbody>792</table>793</section>794<section id="handler-objects">795<span id="handler"></span><h2>Handler Objects<a class="headerlink" href="#handler-objects" title="Link to this heading">¶</a></h2>796<p>Handlers have the following attributes and methods. Note that <a class="reference internal" href="#logging.Handler" title="logging.Handler"><code class="xref py py-class docutils literal notranslate"><span class="pre">Handler</span></code></a>797is never instantiated directly; this class acts as a base for more useful798subclasses. However, the <code class="xref py py-meth docutils literal notranslate"><span class="pre">__init__()</span></code> method in subclasses needs to call799<a class="reference internal" href="#logging.Handler.__init__" title="logging.Handler.__init__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Handler.__init__()</span></code></a>.</p>800<dl class="py class">801<dt class="sig sig-object py" id="logging.Handler">802<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">Handler</span></span><a class="headerlink" href="#logging.Handler" title="Link to this definition">¶</a></dt>803<dd><dl class="py method">804<dt class="sig sig-object py" id="logging.Handler.__init__">805<span class="sig-name descname"><span class="pre">__init__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">level</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">NOTSET</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.__init__" title="Link to this definition">¶</a></dt>806<dd><p>Initializes the <code class="xref py py-class docutils literal notranslate"><span class="pre">Handler</span></code> instance by setting its level, setting the list807of filters to the empty list and creating a lock (using <a class="reference internal" href="#logging.Handler.createLock" title="logging.Handler.createLock"><code class="xref py py-meth docutils literal notranslate"><span class="pre">createLock()</span></code></a>) for808serializing access to an I/O mechanism.</p>809</dd></dl>810 811<dl class="py method">812<dt class="sig sig-object py" id="logging.Handler.createLock">813<span class="sig-name descname"><span class="pre">createLock</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.createLock" title="Link to this definition">¶</a></dt>814<dd><p>Initializes a thread lock which can be used to serialize access to underlying815I/O functionality which may not be threadsafe.</p>816</dd></dl>817 818<dl class="py method">819<dt class="sig sig-object py" id="logging.Handler.acquire">820<span class="sig-name descname"><span class="pre">acquire</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.acquire" title="Link to this definition">¶</a></dt>821<dd><p>Acquires the thread lock created with <a class="reference internal" href="#logging.Handler.createLock" title="logging.Handler.createLock"><code class="xref py py-meth docutils literal notranslate"><span class="pre">createLock()</span></code></a>.</p>822</dd></dl>823 824<dl class="py method">825<dt class="sig sig-object py" id="logging.Handler.release">826<span class="sig-name descname"><span class="pre">release</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.release" title="Link to this definition">¶</a></dt>827<dd><p>Releases the thread lock acquired with <a class="reference internal" href="#logging.Handler.acquire" title="logging.Handler.acquire"><code class="xref py py-meth docutils literal notranslate"><span class="pre">acquire()</span></code></a>.</p>828</dd></dl>829 830<dl class="py method">831<dt class="sig sig-object py" id="logging.Handler.setLevel">832<span class="sig-name descname"><span class="pre">setLevel</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">level</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.setLevel" title="Link to this definition">¶</a></dt>833<dd><p>Sets the threshold for this handler to <em>level</em>. Logging messages which are834less severe than <em>level</em> will be ignored. When a handler is created, the835level is set to <a class="reference internal" href="#logging.NOTSET" title="logging.NOTSET"><code class="xref py py-const docutils literal notranslate"><span class="pre">NOTSET</span></code></a> (which causes all messages to be836processed).</p>837<p>See <a class="reference internal" href="#levels"><span class="std std-ref">Logging Levels</span></a> for a list of levels.</p>838<div class="versionchanged">839<p><span class="versionmodified changed">Changed in version 3.2: </span>The <em>level</em> parameter now accepts a string representation of the840level such as ‘INFO’ as an alternative to the integer constants841such as <a class="reference internal" href="#logging.INFO" title="logging.INFO"><code class="xref py py-const docutils literal notranslate"><span class="pre">INFO</span></code></a>.</p>842</div>843</dd></dl>844 845<dl class="py method">846<dt class="sig sig-object py" id="logging.Handler.setFormatter">847<span class="sig-name descname"><span class="pre">setFormatter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fmt</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.setFormatter" title="Link to this definition">¶</a></dt>848<dd><p>Sets the formatter for this handler to <em>fmt</em>.849The <em>fmt</em> argument must be a <a class="reference internal" href="#logging.Formatter" title="logging.Formatter"><code class="xref py py-class docutils literal notranslate"><span class="pre">Formatter</span></code></a> instance or <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>850</dd></dl>851 852<dl class="py method">853<dt class="sig sig-object py" id="logging.Handler.addFilter">854<span class="sig-name descname"><span class="pre">addFilter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filter</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.addFilter" title="Link to this definition">¶</a></dt>855<dd><p>Adds the specified filter <em>filter</em> to this handler.</p>856</dd></dl>857 858<dl class="py method">859<dt class="sig sig-object py" id="logging.Handler.removeFilter">860<span class="sig-name descname"><span class="pre">removeFilter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filter</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.removeFilter" title="Link to this definition">¶</a></dt>861<dd><p>Removes the specified filter <em>filter</em> from this handler.</p>862</dd></dl>863 864<dl class="py method">865<dt class="sig sig-object py" id="logging.Handler.filter">866<span class="sig-name descname"><span class="pre">filter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.filter" title="Link to this definition">¶</a></dt>867<dd><p>Apply this handler’s filters to the record and return <code class="docutils literal notranslate"><span class="pre">True</span></code> if the868record is to be processed. The filters are consulted in turn, until one of869them returns a false value. If none of them return a false value, the record870will be emitted. If one returns a false value, the handler will not emit the871record.</p>872</dd></dl>873 874<dl class="py method">875<dt class="sig sig-object py" id="logging.Handler.flush">876<span class="sig-name descname"><span class="pre">flush</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.flush" title="Link to this definition">¶</a></dt>877<dd><p>Ensure all logging output has been flushed. This version does nothing and is878intended to be implemented by subclasses.</p>879</dd></dl>880 881<dl class="py method">882<dt class="sig sig-object py" id="logging.Handler.close">883<span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.close" title="Link to this definition">¶</a></dt>884<dd><p>Tidy up any resources used by the handler. This version does no output885but removes the handler from an internal map of handlers, which is used886for handler lookup by name.</p>887<p>Subclasses should ensure that this gets called from overridden <code class="xref py py-meth docutils literal notranslate"><span class="pre">close()</span></code>888methods.</p>889</dd></dl>890 891<dl class="py method">892<dt class="sig sig-object py" id="logging.Handler.handle">893<span class="sig-name descname"><span class="pre">handle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.handle" title="Link to this definition">¶</a></dt>894<dd><p>Conditionally emits the specified logging record, depending on filters which may895have been added to the handler. Wraps the actual emission of the record with896acquisition/release of the I/O thread lock.</p>897</dd></dl>898 899<dl class="py method">900<dt class="sig sig-object py" id="logging.Handler.handleError">901<span class="sig-name descname"><span class="pre">handleError</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.handleError" title="Link to this definition">¶</a></dt>902<dd><p>This method should be called from handlers when an exception is encountered903during an <a class="reference internal" href="#logging.Handler.emit" title="logging.Handler.emit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">emit()</span></code></a> call. If the module-level attribute904<a class="reference internal" href="#logging.raiseExceptions" title="logging.raiseExceptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">raiseExceptions</span></code></a> is <code class="docutils literal notranslate"><span class="pre">False</span></code>, exceptions get silently ignored. This is905what is mostly wanted for a logging system - most users will not care about906errors in the logging system, they are more interested in application907errors. You could, however, replace this with a custom handler if you wish.908The specified record is the one which was being processed when the exception909occurred. (The default value of <code class="xref py py-data docutils literal notranslate"><span class="pre">raiseExceptions</span></code> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, as that is910more useful during development).</p>911</dd></dl>912 913<dl class="py method">914<dt class="sig sig-object py" id="logging.Handler.format">915<span class="sig-name descname"><span class="pre">format</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.format" title="Link to this definition">¶</a></dt>916<dd><p>Do formatting for a record - if a formatter is set, use it. Otherwise, use the917default formatter for the module.</p>918</dd></dl>919 920<dl class="py method">921<dt class="sig sig-object py" id="logging.Handler.emit">922<span class="sig-name descname"><span class="pre">emit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Handler.emit" title="Link to this definition">¶</a></dt>923<dd><p>Do whatever it takes to actually log the specified logging record. This version924is intended to be implemented by subclasses and so raises a925<a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NotImplementedError</span></code></a>.</p>926<div class="admonition warning">927<p class="admonition-title">Warning</p>928<p>This method is called after a handler-level lock is acquired, which929is released after this method returns. When you override this method, note930that you should be careful when calling anything that invokes other parts of931the logging API which might do locking, because that might result in a932deadlock. Specifically:</p>933<ul class="simple">934<li><p>Logging configuration APIs acquire the module-level lock, and then935individual handler-level locks as those handlers are configured.</p></li>936<li><p>Many logging APIs lock the module-level lock. If such an API is called937from this method, it could cause a deadlock if a configuration call is938made on another thread, because that thread will try to acquire the939module-level lock <em>before</em> the handler-level lock, whereas this thread940tries to acquire the module-level lock <em>after</em> the handler-level lock941(because in this method, the handler-level lock has already been acquired).</p></li>942</ul>943</div>944</dd></dl>945 946</dd></dl>947 948<p>For a list of handlers included as standard, see <a class="reference internal" href="logging.handlers.html#module-logging.handlers" title="logging.handlers: Handlers for the logging module."><code class="xref py py-mod docutils literal notranslate"><span class="pre">logging.handlers</span></code></a>.</p>949</section>950<section id="formatter-objects">951<span id="id1"></span><h2>Formatter Objects<a class="headerlink" href="#formatter-objects" title="Link to this heading">¶</a></h2>952<dl class="py class">953<dt class="sig sig-object py" id="logging.Formatter">954<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">Formatter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">datefmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">style</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'%'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">validate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">defaults</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Formatter" title="Link to this definition">¶</a></dt>955<dd><p>Responsible for converting a <a class="reference internal" href="#logging.LogRecord" title="logging.LogRecord"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code></a> to an output string956to be interpreted by a human or external system.</p>957<dl class="field-list simple">958<dt class="field-odd">Parameters<span class="colon">:</span></dt>959<dd class="field-odd"><ul class="simple">960<li><p><strong>fmt</strong> (<a class="reference internal" href="stdtypes.html#str" title="str"><em>str</em></a>) – A format string in the given <em>style</em> for961the logged output as a whole.962The possible mapping keys are drawn from the <a class="reference internal" href="#logging.LogRecord" title="logging.LogRecord"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code></a> object’s963<a class="reference internal" href="#logrecord-attributes"><span class="std std-ref">LogRecord attributes</span></a>.964If not specified, <code class="docutils literal notranslate"><span class="pre">'%(message)s'</span></code> is used,965which is just the logged message.</p></li>966<li><p><strong>datefmt</strong> (<a class="reference internal" href="stdtypes.html#str" title="str"><em>str</em></a>) – A format string for the date/time portion of the logged output.967If not specified, the default described in <a class="reference internal" href="#logging.Formatter.formatTime" title="logging.Formatter.formatTime"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatTime()</span></code></a> is used.</p></li>968<li><p><strong>style</strong> (<a class="reference internal" href="stdtypes.html#str" title="str"><em>str</em></a>) – Can be one of <code class="docutils literal notranslate"><span class="pre">'%'</span></code>, <code class="docutils literal notranslate"><span class="pre">'{'</span></code> or <code class="docutils literal notranslate"><span class="pre">'$'</span></code> and determines969how the format string will be merged with its data: using one of970<a class="reference internal" href="stdtypes.html#old-string-formatting"><span class="std std-ref">printf-style String Formatting</span></a> (<code class="docutils literal notranslate"><span class="pre">%</span></code>), <a class="reference internal" href="stdtypes.html#str.format" title="str.format"><code class="xref py py-meth docutils literal notranslate"><span class="pre">str.format()</span></code></a> (<code class="docutils literal notranslate"><span class="pre">{</span></code>)971or <a class="reference internal" href="string.html#string.Template" title="string.Template"><code class="xref py py-class docutils literal notranslate"><span class="pre">string.Template</span></code></a> (<code class="docutils literal notranslate"><span class="pre">$</span></code>). This only applies to972<em>fmt</em> (e.g. <code class="docutils literal notranslate"><span class="pre">'%(message)s'</span></code> versus <code class="docutils literal notranslate"><span class="pre">'{message}'</span></code>),973not to the actual log messages passed to the logging methods.974However, there are <a class="reference internal" href="../howto/logging-cookbook.html#formatting-styles"><span class="std std-ref">other ways</span></a>975to use <code class="docutils literal notranslate"><span class="pre">{</span></code>- and <code class="docutils literal notranslate"><span class="pre">$</span></code>-formatting for log messages.</p></li>976<li><p><strong>validate</strong> (<a class="reference internal" href="functions.html#bool" title="bool"><em>bool</em></a>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code> (the default), incorrect or mismatched977<em>fmt</em> and <em>style</em> will raise a <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>; for example,978<code class="docutils literal notranslate"><span class="pre">logging.Formatter('%(asctime)s</span> <span class="pre">-</span> <span class="pre">%(message)s',</span> <span class="pre">style='{')</span></code>.</p></li>979<li><p><strong>defaults</strong> (<a class="reference internal" href="stdtypes.html#dict" title="dict"><em>dict</em></a><em>[</em><a class="reference internal" href="stdtypes.html#str" title="str"><em>str</em></a><em>, </em><em>Any</em><em>]</em>) – A dictionary with default values to use in custom fields.980For example,981<code class="docutils literal notranslate"><span class="pre">logging.Formatter('%(ip)s</span> <span class="pre">%(message)s',</span> <span class="pre">defaults={&quot;ip&quot;:</span> <span class="pre">None})</span></code></p></li>982</ul>983</dd>984</dl>985<div class="versionchanged">986<p><span class="versionmodified changed">Changed in version 3.2: </span>Added the <em>style</em> parameter.</p>987</div>988<div class="versionchanged">989<p><span class="versionmodified changed">Changed in version 3.8: </span>Added the <em>validate</em> parameter.</p>990</div>991<div class="versionchanged">992<p><span class="versionmodified changed">Changed in version 3.10: </span>Added the <em>defaults</em> parameter.</p>993</div>994<dl class="py method">995<dt class="sig sig-object py" id="logging.Formatter.format">996<span class="sig-name descname"><span class="pre">format</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Formatter.format" title="Link to this definition">¶</a></dt>997<dd><p>The record’s attribute dictionary is used as the operand to a string998formatting operation. Returns the resulting string. Before formatting the999dictionary, a couple of preparatory steps are carried out. The <em>message</em>1000attribute of the record is computed using <em>msg</em> % <em>args</em>. If the1001formatting string contains <code class="docutils literal notranslate"><span class="pre">'(asctime)'</span></code>, <a class="reference internal" href="#logging.Formatter.formatTime" title="logging.Formatter.formatTime"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatTime()</span></code></a> is called1002to format the event time. If there is exception information, it is1003formatted using <a class="reference internal" href="#logging.Formatter.formatException" title="logging.Formatter.formatException"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatException()</span></code></a> and appended to the message. Note1004that the formatted exception information is cached in attribute1005<em>exc_text</em>. This is useful because the exception information can be1006pickled and sent across the wire, but you should be careful if you have1007more than one <code class="xref py py-class docutils literal notranslate"><span class="pre">Formatter</span></code> subclass which customizes the formatting1008of exception information. In this case, you will have to clear the cached1009value (by setting the <em>exc_text</em> attribute to <code class="docutils literal notranslate"><span class="pre">None</span></code>) after a formatter1010has done its formatting, so that the next formatter to handle the event1011doesn’t use the cached value, but recalculates it afresh.</p>1012<p>If stack information is available, it’s appended after the exception1013information, using <a class="reference internal" href="#logging.Formatter.formatStack" title="logging.Formatter.formatStack"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatStack()</span></code></a> to transform it if necessary.</p>1014</dd></dl>1015 1016<dl class="py method">1017<dt class="sig sig-object py" id="logging.Formatter.formatTime">1018<span class="sig-name descname"><span class="pre">formatTime</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">datefmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Formatter.formatTime" title="Link to this definition">¶</a></dt>1019<dd><p>This method should be called from <a class="reference internal" href="functions.html#format" title="format"><code class="xref py py-meth docutils literal notranslate"><span class="pre">format()</span></code></a> by a formatter which1020wants to make use of a formatted time. This method can be overridden in1021formatters to provide for any specific requirement, but the basic behavior1022is as follows: if <em>datefmt</em> (a string) is specified, it is used with1023<a class="reference internal" href="time.html#time.strftime" title="time.strftime"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.strftime()</span></code></a> to format the creation time of the1024record. Otherwise, the format ‘%Y-%m-%d %H:%M:%S,uuu’ is used, where the1025uuu part is a millisecond value and the other letters are as per the1026<code class="xref py py-func docutils literal notranslate"><span class="pre">time.strftime()</span></code> documentation.  An example time in this format is1027<code class="docutils literal notranslate"><span class="pre">2003-01-23</span> <span class="pre">00:29:50,411</span></code>.  The resulting string is returned.</p>1028<p>This function uses a user-configurable function to convert the creation1029time to a tuple. By default, <a class="reference internal" href="time.html#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.localtime()</span></code></a> is used; to change1030this for a particular formatter instance, set the <code class="docutils literal notranslate"><span class="pre">converter</span></code> attribute1031to a function with the same signature as <code class="xref py py-func docutils literal notranslate"><span class="pre">time.localtime()</span></code> or1032<a class="reference internal" href="time.html#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.gmtime()</span></code></a>. To change it for all formatters, for example if you1033want all logging times to be shown in GMT, set the <code class="docutils literal notranslate"><span class="pre">converter</span></code>1034attribute in the <code class="docutils literal notranslate"><span class="pre">Formatter</span></code> class.</p>1035<div class="versionchanged">1036<p><span class="versionmodified changed">Changed in version 3.3: </span>Previously, the default format was hard-coded as in this example:1037<code class="docutils literal notranslate"><span class="pre">2010-09-06</span> <span class="pre">22:38:15,292</span></code> where the part before the comma is1038handled by a strptime format string (<code class="docutils literal notranslate"><span class="pre">'%Y-%m-%d</span> <span class="pre">%H:%M:%S'</span></code>), and the1039part after the comma is a millisecond value. Because strptime does not1040have a format placeholder for milliseconds, the millisecond value is1041appended using another format string, <code class="docutils literal notranslate"><span class="pre">'%s,%03d'</span></code> — and both of these1042format strings have been hardcoded into this method. With the change,1043these strings are defined as class-level attributes which can be1044overridden at the instance level when desired. The names of the1045attributes are <code class="docutils literal notranslate"><span class="pre">default_time_format</span></code> (for the strptime format string)1046and <code class="docutils literal notranslate"><span class="pre">default_msec_format</span></code> (for appending the millisecond value).</p>1047</div>1048<div class="versionchanged">1049<p><span class="versionmodified changed">Changed in version 3.9: </span>The <code class="docutils literal notranslate"><span class="pre">default_msec_format</span></code> can be <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>1050</div>1051</dd></dl>1052 1053<dl class="py method">1054<dt class="sig sig-object py" id="logging.Formatter.formatException">1055<span class="sig-name descname"><span class="pre">formatException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">exc_info</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Formatter.formatException" title="Link to this definition">¶</a></dt>1056<dd><p>Formats the specified exception information (a standard exception tuple as1057returned by <a class="reference internal" href="sys.html#sys.exc_info" title="sys.exc_info"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.exc_info()</span></code></a>) as a string. This default implementation1058just uses <a class="reference internal" href="traceback.html#traceback.print_exception" title="traceback.print_exception"><code class="xref py py-func docutils literal notranslate"><span class="pre">traceback.print_exception()</span></code></a>. The resulting string is1059returned.</p>1060</dd></dl>1061 1062<dl class="py method">1063<dt class="sig sig-object py" id="logging.Formatter.formatStack">1064<span class="sig-name descname"><span class="pre">formatStack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack_info</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Formatter.formatStack" title="Link to this definition">¶</a></dt>1065<dd><p>Formats the specified stack information (a string as returned by1066<a class="reference internal" href="traceback.html#traceback.print_stack" title="traceback.print_stack"><code class="xref py py-func docutils literal notranslate"><span class="pre">traceback.print_stack()</span></code></a>, but with the last newline removed) as a1067string. This default implementation just returns the input value.</p>1068</dd></dl>1069 1070</dd></dl>1071 1072<dl class="py class">1073<dt class="sig sig-object py" id="logging.BufferingFormatter">1074<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">BufferingFormatter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">linefmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.BufferingFormatter" title="Link to this definition">¶</a></dt>1075<dd><p>A base formatter class suitable for subclassing when you want to format a1076number of records. You can pass a <a class="reference internal" href="#logging.Formatter" title="logging.Formatter"><code class="xref py py-class docutils literal notranslate"><span class="pre">Formatter</span></code></a> instance which you want1077to use to format each line (that corresponds to a single record). If not1078specified, the default formatter (which just outputs the event message) is1079used as the line formatter.</p>1080<dl class="py method">1081<dt class="sig sig-object py" id="logging.BufferingFormatter.formatHeader">1082<span class="sig-name descname"><span class="pre">formatHeader</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">records</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.BufferingFormatter.formatHeader" title="Link to this definition">¶</a></dt>1083<dd><p>Return a header for a list of <em>records</em>. The base implementation just1084returns the empty string. You will need to override this method if you1085want specific behaviour, e.g. to show the count of records, a title or a1086separator line.</p>1087</dd></dl>1088 1089<dl class="py method">1090<dt class="sig sig-object py" id="logging.BufferingFormatter.formatFooter">1091<span class="sig-name descname"><span class="pre">formatFooter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">records</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.BufferingFormatter.formatFooter" title="Link to this definition">¶</a></dt>1092<dd><p>Return a footer for a list of <em>records</em>. The base implementation just1093returns the empty string. You will need to override this method if you1094want specific behaviour, e.g. to show the count of records or a separator1095line.</p>1096</dd></dl>1097 1098<dl class="py method">1099<dt class="sig sig-object py" id="logging.BufferingFormatter.format">1100<span class="sig-name descname"><span class="pre">format</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">records</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.BufferingFormatter.format" title="Link to this definition">¶</a></dt>1101<dd><p>Return formatted text for a list of <em>records</em>. The base implementation1102just returns the empty string if there are no records; otherwise, it1103returns the concatenation of the header, each record formatted with the1104line formatter, and the footer.</p>1105</dd></dl>1106 1107</dd></dl>1108 1109</section>1110<section id="filter-objects">1111<span id="filter"></span><h2>Filter Objects<a class="headerlink" href="#filter-objects" title="Link to this heading">¶</a></h2>1112<p><code class="docutils literal notranslate"><span class="pre">Filters</span></code> can be used by <code class="docutils literal notranslate"><span class="pre">Handlers</span></code> and <code class="docutils literal notranslate"><span class="pre">Loggers</span></code> for more sophisticated1113filtering than is provided by levels. The base filter class only allows events1114which are below a certain point in the logger hierarchy. For example, a filter1115initialized with ‘A.B’ will allow events logged by loggers ‘A.B’, ‘A.B.C’,1116‘A.B.C.D’, ‘A.B.D’ etc. but not ‘A.BB’, ‘B.A.B’ etc. If initialized with the1117empty string, all events are passed.</p>1118<dl class="py class">1119<dt class="sig sig-object py" id="logging.Filter">1120<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">Filter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Filter" title="Link to this definition">¶</a></dt>1121<dd><p>Returns an instance of the <code class="xref py py-class docutils literal notranslate"><span class="pre">Filter</span></code> class. If <em>name</em> is specified, it1122names a logger which, together with its children, will have its events allowed1123through the filter. If <em>name</em> is the empty string, allows every event.</p>1124<dl class="py method">1125<dt class="sig sig-object py" id="logging.Filter.filter">1126<span class="sig-name descname"><span class="pre">filter</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">record</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.Filter.filter" title="Link to this definition">¶</a></dt>1127<dd><p>Is the specified record to be logged? Returns false for no, true for1128yes. Filters can either modify log records in-place or return a completely1129different record instance which will replace the original1130log record in any future processing of the event.</p>1131</dd></dl>1132 1133</dd></dl>1134 1135<p>Note that filters attached to handlers are consulted before an event is1136emitted by the handler, whereas filters attached to loggers are consulted1137whenever an event is logged (using <a class="reference internal" href="#logging.debug" title="logging.debug"><code class="xref py py-meth docutils literal notranslate"><span class="pre">debug()</span></code></a>, <a class="reference internal" href="#logging.info" title="logging.info"><code class="xref py py-meth docutils literal notranslate"><span class="pre">info()</span></code></a>,1138etc.), before sending an event to handlers. This means that events which have1139been generated by descendant loggers will not be filtered by a logger’s filter1140setting, unless the filter has also been applied to those descendant loggers.</p>1141<p>You don’t actually need to subclass <code class="docutils literal notranslate"><span class="pre">Filter</span></code>: you can pass any instance1142which has a <code class="docutils literal notranslate"><span class="pre">filter</span></code> method with the same semantics.</p>1143<div class="versionchanged">1144<p><span class="versionmodified changed">Changed in version 3.2: </span>You don’t need to create specialized <code class="docutils literal notranslate"><span class="pre">Filter</span></code> classes, or use other1145classes with a <code class="docutils literal notranslate"><span class="pre">filter</span></code> method: you can use a function (or other1146callable) as a filter. The filtering logic will check to see if the filter1147object has a <code class="docutils literal notranslate"><span class="pre">filter</span></code> attribute: if it does, it’s assumed to be a1148<code class="docutils literal notranslate"><span class="pre">Filter</span></code> and its <a class="reference internal" href="#logging.Filter.filter" title="logging.Filter.filter"><code class="xref py py-meth docutils literal notranslate"><span class="pre">filter()</span></code></a> method is called. Otherwise, it’s1149assumed to be a callable and called with the record as the single1150parameter. The returned value should conform to that returned by1151<code class="xref py py-meth docutils literal notranslate"><span class="pre">filter()</span></code>.</p>1152</div>1153<div class="versionchanged">1154<p><span class="versionmodified changed">Changed in version 3.12: </span>You can now return a <a class="reference internal" href="#logging.LogRecord" title="logging.LogRecord"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code></a> instance from filters to replace1155the log record rather than modifying it in place. This allows filters attached to1156a <a class="reference internal" href="#logging.Handler" title="logging.Handler"><code class="xref py py-class docutils literal notranslate"><span class="pre">Handler</span></code></a> to modify the log record before it is emitted, without1157having side effects on other handlers.</p>1158</div>1159<p>Although filters are used primarily to filter records based on more1160sophisticated criteria than levels, they get to see every record which is1161processed by the handler or logger they’re attached to: this can be useful if1162you want to do things like counting how many records were processed by a1163particular logger or handler, or adding, changing or removing attributes in1164the <a class="reference internal" href="#logging.LogRecord" title="logging.LogRecord"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code></a> being processed. Obviously changing the LogRecord needs1165to be done with some care, but it does allow the injection of contextual1166information into logs (see <a class="reference internal" href="../howto/logging-cookbook.html#filters-contextual"><span class="std std-ref">Using Filters to impart contextual information</span></a>).</p>1167</section>1168<section id="logrecord-objects">1169<span id="log-record"></span><h2>LogRecord Objects<a class="headerlink" href="#logrecord-objects" title="Link to this heading">¶</a></h2>1170<p><a class="reference internal" href="#logging.LogRecord" title="logging.LogRecord"><code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code></a> instances are created automatically by the <a class="reference internal" href="#logging.Logger" title="logging.Logger"><code class="xref py py-class docutils literal notranslate"><span class="pre">Logger</span></code></a>1171every time something is logged, and can be created manually via1172<a class="reference internal" href="#logging.makeLogRecord" title="logging.makeLogRecord"><code class="xref py py-func docutils literal notranslate"><span class="pre">makeLogRecord()</span></code></a> (for example, from a pickled event received over the1173wire).</p>1174<dl class="py class">1175<dt class="sig sig-object py" id="logging.LogRecord">1176<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">logging.</span></span><span class="sig-name descname"><span class="pre">LogRecord</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">level</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pathname</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lineno</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exc_info</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sinfo</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#logging.LogRecord" title="Link to this definition">¶</a></dt>1177<dd><p>Contains all the information pertinent to the event being logged.</p>1178<p>The primary information is passed in <em>msg</em> and <em>args</em>,1179which are combined using <code class="docutils literal notranslate"><span class="pre">msg</span> <span class="pre">%</span> <span class="pre">args</span></code> to create1180the <code class="xref py py-attr docutils literal notranslate"><span class="pre">message</span></code> attribute of the record.</p>1181<dl class="field-list simple">1182<dt class="field-odd">Parameters<span class="colon">:</span></dt>1183<dd class="field-odd"><ul class="simple">1184<li><p><strong>name</strong> (<a class="reference internal" href="stdtypes.html#str" title="str"><em>str</em></a>) – The name of the logger used to log the event1185represented by this <code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code>.1186Note that the logger name in the <code class="xref py py-class docutils literal notranslate"><span class="pre">LogRecord</span></code>1187will always have this value,1188even though it may be emitted by a handler1189attached to a different (ancestor) logger.</p></li>1190<li><p><strong>level</strong> (<a class="reference internal" href="functions.html#int" title="int"><em>int</em></a>) – The <a class="reference internal" href="#levels"><span class="std std-ref">numeric level</span></a> of the logging event1191(such as <code class="docutils literal notranslate"><span class="pre">10</span></code> for <code class="docutils literal notranslate"><span class="pre">DEBUG</span></code>, <code class="docutils literal notranslate"><span class="pre">20</span></code> for <code class="docutils literal notranslate"><span class="pre">INFO</span></code>, etc).1192Note that this is converted to <em>two</em> attributes of the LogRecord:1193<code class="xref py py-attr docutils literal notranslate"><span class="pre">levelno</span></code> for the numeric value1194and <code class="xref py py-attr docutils literal notranslate"><span class="pre">levelname</span></code> for the corresponding level name.</p></li>1195<li><p><strong>pathname</strong> (<a class="reference internal" href="stdtypes.html#str" title="str"><em>str</em></a>) – The full string path of the source file1196where the logging call was made.</p></li>1197<li><p><strong>lineno</strong> (<a class="reference internal" href="functions.html#int" title="int"><em>int</em></a>) – The line number in the source file1198where the logging call was made.</p></li>1199<li><p><strong>msg</strong> (<a class="reference internal" href="typing.html#typing.Any" title="typing.Any"><em>Any</em></a>) – The event description message,1200which can be a %-format string with placeholders for variable data,

Showing the first 1,200 of 2144 lines. Download the file for the rest.