Package cherrypy :: Module _cplogging :: Class LogManager
[hide private]
[frames] | no frames]

Class LogManager

source code

object --+
         |
        LogManager
Known Subclasses:

An object to assist both simple and advanced logging.

``cherrypy.log`` is an instance of this class.

Instance Methods [hide private]
 
__init__(self, appid=None, logger_root='cherrypy')
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
reopen_files(self)
Close and reopen all file handlers.
source code
 
error(self, msg='', context='', severity=20, traceback=False)
Write the given ``msg`` to the error log.
source code
 
__call__(self, *args, **kwargs)
An alias for ``error``.
source code
 
access(self)
Write to the access log (in Apache/NCSA Combined Log format).
source code
 
time(self)
Return now() in Apache Common Log Format (no timezone).
source code
 
_get_builtin_handler(self, log, key) source code
 
_set_screen_handler(self, log, enable, stream=None) source code
 
_get_screen(self) source code
 
_set_screen(self, newvalue) source code
 
_add_builtin_file_handler(self, log, fname) source code
 
_set_file_handler(self, log, filename) source code
 
_get_error_file(self) source code
 
_set_error_file(self, newvalue) source code
 
_get_access_file(self) source code
 
_set_access_file(self, newvalue) source code
 
_set_wsgi_handler(self, log, enable) source code
 
_get_wsgi(self) source code
 
_set_wsgi(self, newvalue) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  appid = None
The id() of the Application object which owns this log manager.
  error_log = None
The actual :class:`logging.Logger` instance for error messages.
  access_log = None
The actual :class:`logging.Logger` instance for access messages.
  access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b...
  logger_root = None
The "top-level" logger name.
Properties [hide private]
  screen
Turn stderr/stdout logging on or off.
  error_file
The filename for self.error_log.
  access_file
The filename for self.access_log.
  wsgi
Write errors to wsgi.errors.

Inherited from object: __class__

Method Details [hide private]

__init__(self, appid=None, logger_root='cherrypy')
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

error(self, msg='', context='', severity=20, traceback=False)

source code 

Write the given ``msg`` to the error log.

This is not just for errors! Applications may call this at any time to log application-specific information.

If ``traceback`` is True, the traceback of the current exception (if any) will be appended to ``msg``.

access(self)

source code 

Write to the access log (in Apache/NCSA Combined Log format).

See the `apache documentation <http://httpd.apache.org/docs/current/logs.html#combined>`_ for format details.

CherryPy calls this automatically for you. Note there are no arguments; it collects the data itself from :class:`cherrypy.request<cherrypy._cprequest.Request>`.

Like Apache started doing in 2.0.46, non-printable and other special characters in %r (and we expand that to all parts) are escaped using \xhh sequences, where hh stands for the hexadecimal representation of the raw byte. Exceptions from this rule are " and \, which are escaped by prepending a backslash, and all whitespace characters, which are written in their C-style notation (\n, \t, etc).


Class Variable Details [hide private]

appid

The id() of the Application object which owns this log manager. If this is a global log manager, appid is None.

Value:
None

access_log_format

Value:
'%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'

logger_root

The "top-level" logger name.

This string will be used as the first segment in the Logger names. The default is "cherrypy", for example, in which case the Logger names will be of the form:

   cherrypy.error.<appid>
   cherrypy.access.<appid>
Value:
None

Property Details [hide private]

screen

Turn stderr/stdout logging on or off.

If you set this to True, it'll add the appropriate StreamHandler for you. If you set it to False, it will remove the handler.

Get Method:
_get_screen(self)
Set Method:
_set_screen(self, newvalue)

error_file

The filename for self.error_log.

If you set this to a string, it'll add the appropriate FileHandler for you. If you set it to ``None`` or ``''``, it will remove the handler.

Get Method:
_get_error_file(self)
Set Method:
_set_error_file(self, newvalue)

access_file

The filename for self.access_log.

If you set this to a string, it'll add the appropriate FileHandler for you. If you set it to ``None`` or ``''``, it will remove the handler.

Get Method:
_get_access_file(self)
Set Method:
_set_access_file(self, newvalue)

wsgi

Write errors to wsgi.errors.

If you set this to True, it'll add the appropriate :class:`WSGIErrorHandler<cherrypy._cplogging.WSGIErrorHandler>` for you (which writes errors to ``wsgi.errors``). If you set it to False, it will remove the handler.

Get Method:
_get_wsgi(self)
Set Method:
_set_wsgi(self, newvalue)