2015-12-27 01:55:59 +01:00
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
|
<html><head><title>Python: module log</title>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
|
</head><body bgcolor="#f0f0f8">
|
|
|
|
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
|
|
<tr bgcolor="#7799ee">
|
|
|
|
<td valign=bottom> <br>
|
|
|
|
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>log</strong></big></big></font></td
|
|
|
|
><td align=right valign=bottom
|
|
|
|
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/gl/pylink/log.py">/home/gl/pylink/log.py</a></font></td></tr></table>
|
|
|
|
<p><tt>log.py - PyLink logging module.<br>
|
|
|
|
<br>
|
|
|
|
This module contains the logging portion of the PyLink framework. Plugins can<br>
|
|
|
|
access the global logger object by importing "log" from this module<br>
|
|
|
|
(from log import log).</tt></p>
|
|
|
|
<p>
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
|
|
<tr bgcolor="#aa55cc">
|
|
|
|
<td colspan=3 valign=bottom> <br>
|
|
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
|
|
|
|
|
|
|
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
|
|
|
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="logging.html">logging</a><br>
|
|
|
|
</td><td width="25%" valign=top><a href="os.html">os</a><br>
|
|
|
|
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
|
2016-05-12 06:56:02 +02:00
|
|
|
</td><td width="25%" valign=top><a href="world.html">world</a><br>
|
|
|
|
</td></tr></table></td></tr></table><p>
|
2015-12-27 01:55:59 +01:00
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
2016-03-12 08:13:55 +01:00
|
|
|
<tr bgcolor="#ee77aa">
|
|
|
|
<td colspan=3 valign=bottom> <br>
|
|
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
|
|
|
|
|
|
|
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
|
|
|
<td width="100%"><dl>
|
|
|
|
<dt><font face="helvetica, arial"><a href="logging.html#Handler">logging.Handler</a>(<a href="logging.html#Filterer">logging.Filterer</a>)
|
|
|
|
</font></dt><dd>
|
|
|
|
<dl>
|
|
|
|
<dt><font face="helvetica, arial"><a href="log.html#PyLinkChannelLogger">PyLinkChannelLogger</a>
|
|
|
|
</font></dt></dl>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
<p>
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
|
|
<tr bgcolor="#ffc8d8">
|
|
|
|
<td colspan=3 valign=bottom> <br>
|
|
|
|
<font color="#000000" face="helvetica, arial"><a name="PyLinkChannelLogger">class <strong>PyLinkChannelLogger</strong></a>(<a href="logging.html#Handler">logging.Handler</a>)</font></td></tr>
|
|
|
|
|
|
|
|
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
|
|
|
<td colspan=2><tt>Log handler to log to channels in PyLink.<br> </tt></td></tr>
|
|
|
|
<tr><td> </td>
|
|
|
|
<td width="100%"><dl><dt>Method resolution order:</dt>
|
|
|
|
<dd><a href="log.html#PyLinkChannelLogger">PyLinkChannelLogger</a></dd>
|
|
|
|
<dd><a href="logging.html#Handler">logging.Handler</a></dd>
|
|
|
|
<dd><a href="logging.html#Filterer">logging.Filterer</a></dd>
|
|
|
|
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
|
|
|
</dl>
|
|
|
|
<hr>
|
|
|
|
Methods defined here:<br>
|
2016-05-28 07:39:27 +02:00
|
|
|
<dl><dt><a name="PyLinkChannelLogger-__init__"><strong>__init__</strong></a>(self, irc, channel, level=None)</dt><dd><tt>Initializes the instance - basically setting the formatter to None<br>
|
|
|
|
and the filter list to empty.</tt></dd></dl>
|
2016-03-12 08:13:55 +01:00
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-emit"><strong>emit</strong></a>(self, record)</dt><dd><tt>Logs a record to the configured channels for the network given.</tt></dd></dl>
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
Methods inherited from <a href="logging.html#Handler">logging.Handler</a>:<br>
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-acquire"><strong>acquire</strong></a>(self)</dt><dd><tt>Acquire the I/O thread lock.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-close"><strong>close</strong></a>(self)</dt><dd><tt>Tidy up any resources used by the handler.<br>
|
|
|
|
<br>
|
|
|
|
This version removes the handler from an internal map of handlers,<br>
|
|
|
|
_handlers, which is used for handler lookup by name. Subclasses<br>
|
|
|
|
should ensure that this gets called from overridden <a href="#PyLinkChannelLogger-close">close</a>()<br>
|
|
|
|
methods.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-createLock"><strong>createLock</strong></a>(self)</dt><dd><tt>Acquire a thread lock for serializing access to the underlying I/O.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-flush"><strong>flush</strong></a>(self)</dt><dd><tt>Ensure all logging output has been flushed.<br>
|
|
|
|
<br>
|
|
|
|
This version does nothing and is intended to be implemented by<br>
|
|
|
|
subclasses.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-format"><strong>format</strong></a>(self, record)</dt><dd><tt>Format the specified record.<br>
|
|
|
|
<br>
|
|
|
|
If a formatter is set, use it. Otherwise, use the default formatter<br>
|
|
|
|
for the module.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-get_name"><strong>get_name</strong></a>(self)</dt></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-handle"><strong>handle</strong></a>(self, record)</dt><dd><tt>Conditionally emit the specified logging record.<br>
|
|
|
|
<br>
|
|
|
|
Emission depends on filters which may have been added to the handler.<br>
|
|
|
|
Wrap the actual emission of the record with acquisition/release of<br>
|
|
|
|
the I/O thread lock. Returns whether the filter passed the record for<br>
|
|
|
|
emission.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-handleError"><strong>handleError</strong></a>(self, record)</dt><dd><tt>Handle errors which occur during an <a href="#PyLinkChannelLogger-emit">emit</a>() call.<br>
|
|
|
|
<br>
|
|
|
|
This method should be called from handlers when an exception is<br>
|
|
|
|
encountered during an <a href="#PyLinkChannelLogger-emit">emit</a>() call. If raiseExceptions is false,<br>
|
|
|
|
exceptions get silently ignored. This is what is mostly wanted<br>
|
|
|
|
for a logging system - most users will not care about errors in<br>
|
|
|
|
the logging system, they are more interested in application errors.<br>
|
|
|
|
You could, however, replace this with a custom handler if you wish.<br>
|
|
|
|
The record which was being processed is passed in to this method.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-release"><strong>release</strong></a>(self)</dt><dd><tt>Release the I/O thread lock.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-setFormatter"><strong>setFormatter</strong></a>(self, fmt)</dt><dd><tt>Set the formatter for this handler.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-setLevel"><strong>setLevel</strong></a>(self, level)</dt><dd><tt>Set the logging level of this handler. level must be an int or a str.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-set_name"><strong>set_name</strong></a>(self, name)</dt></dl>
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
Data descriptors inherited from <a href="logging.html#Handler">logging.Handler</a>:<br>
|
|
|
|
<dl><dt><strong>name</strong></dt>
|
|
|
|
</dl>
|
|
|
|
<hr>
|
|
|
|
Methods inherited from <a href="logging.html#Filterer">logging.Filterer</a>:<br>
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-addFilter"><strong>addFilter</strong></a>(self, filter)</dt><dd><tt>Add the specified filter to this handler.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-filter"><strong>filter</strong></a>(self, record)</dt><dd><tt>Determine if a record is loggable by consulting all the filters.<br>
|
|
|
|
<br>
|
|
|
|
The default is to allow the record to be logged; any filter can veto<br>
|
|
|
|
this and the record is then dropped. Returns a zero value if a record<br>
|
|
|
|
is to be dropped, else non-zero.<br>
|
|
|
|
<br>
|
2016-05-28 07:39:27 +02:00
|
|
|
.. versionchanged:: 3.2<br>
|
2016-03-12 08:13:55 +01:00
|
|
|
<br>
|
|
|
|
Allow filters to be just callables.</tt></dd></dl>
|
|
|
|
|
|
|
|
<dl><dt><a name="PyLinkChannelLogger-removeFilter"><strong>removeFilter</strong></a>(self, filter)</dt><dd><tt>Remove the specified filter from this handler.</tt></dd></dl>
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
Data descriptors inherited from <a href="logging.html#Filterer">logging.Filterer</a>:<br>
|
|
|
|
<dl><dt><strong>__dict__</strong></dt>
|
|
|
|
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
|
|
|
</dl>
|
|
|
|
<dl><dt><strong>__weakref__</strong></dt>
|
|
|
|
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
|
|
|
</dl>
|
|
|
|
</td></tr></table></td></tr></table><p>
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
|
|
<tr bgcolor="#eeaa77">
|
|
|
|
<td colspan=3 valign=bottom> <br>
|
|
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
|
|
|
|
|
|
|
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
|
|
|
<td width="100%"><dl><dt><a name="-makeFileLogger"><strong>makeFileLogger</strong></a>(filename, level=None)</dt><dd><tt>Initializes a file logging target with the given filename and level.</tt></dd></dl>
|
|
|
|
</td></tr></table><p>
|
|
|
|
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
2015-12-27 01:55:59 +01:00
|
|
|
<tr bgcolor="#55aa55">
|
|
|
|
<td colspan=3 valign=bottom> <br>
|
|
|
|
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
|
|
|
|
|
|
|
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
2016-05-28 07:39:27 +02:00
|
|
|
<td width="100%"><strong>conf</strong> = {'bot': {'nick': 'PyLink', 'realname': 'PyLink Service Client', 'serverdesc': 'PyLink unit tests', 'user': 'pylink'}, 'logging': {'stdout': 'CRITICAL'}, 'servers': defaultdict(<function <lambda> at 0x7f496c510e18>, {})}<br>
|
2015-12-27 01:55:59 +01:00
|
|
|
<strong>confname</strong> = 'testconf'<br>
|
|
|
|
<strong>curdir</strong> = '/home/gl/pylink'<br>
|
2016-03-12 08:13:55 +01:00
|
|
|
<strong>files</strong> = None<br>
|
2015-12-27 01:55:59 +01:00
|
|
|
<strong>log</strong> = <logging.RootLogger object><br>
|
|
|
|
<strong>logdir</strong> = '/home/gl/pylink/log'<br>
|
2016-03-12 08:13:55 +01:00
|
|
|
<strong>logformatter</strong> = <logging.Formatter object><br>
|
|
|
|
<strong>stdout_level</strong> = 'CRITICAL'</td></tr></table>
|
2015-12-27 01:55:59 +01:00
|
|
|
</body></html>
|