Package logging :: Module handlers :: Class SysLogHandler
[hide private]
[frames] | no frames]

_ClassType SysLogHandler

Filterer --+    
           |    
     Handler --+
               |
              SysLogHandler

A handler class which sends formatted logging records to a syslog server. Based on Sam Rushing's syslog module: http://www.nightmare.com/squirl/python-ext/misc/syslog.py Contributed by Nicolas Untz (after which minor refactoring changes have been made).

Instance Methods [hide private]
 
__init__(self, address=('localhost', 514), facility=1)
Initialize a handler.
 
_connect_unixsocket(self, address)
 
encodePriority(self, facility, priority)
Encode the facility and priority.
 
close(self)
Closes the socket.
 
mapPriority(self, levelName)
Map a logging level name to a key in the priority_names map.
 
emit(self, record)
Emit a record.

Inherited from Handler: acquire, createLock, flush, format, handle, handleError, release, setFormatter, setLevel

Inherited from Filterer: addFilter, filter, removeFilter

Class Variables [hide private]
  LOG_EMERG = 0
  LOG_ALERT = 1
  LOG_CRIT = 2
  LOG_ERR = 3
  LOG_WARNING = 4
  LOG_NOTICE = 5
  LOG_INFO = 6
  LOG_DEBUG = 7
  LOG_KERN = 0
  LOG_USER = 1
  LOG_MAIL = 2
  LOG_DAEMON = 3
  LOG_AUTH = 4
  LOG_SYSLOG = 5
  LOG_LPR = 6
  LOG_NEWS = 7
  LOG_UUCP = 8
  LOG_CRON = 9
  LOG_AUTHPRIV = 10
  LOG_LOCAL0 = 16
  LOG_LOCAL1 = 17
  LOG_LOCAL2 = 18
  LOG_LOCAL3 = 19
  LOG_LOCAL4 = 20
  LOG_LOCAL5 = 21
  LOG_LOCAL6 = 22
  LOG_LOCAL7 = 23
  priority_names = {'alert': 1, 'crit': 2, 'critical': 2, 'debug...
  facility_names = {'auth': 4, 'authpriv': 10, 'cron': 9, 'daemo...
  priority_map = {'CRITICAL': 'critical', 'DEBUG': 'debug', 'ERR...
  log_format_string = '<%d>%s\x00'
Method Details [hide private]

__init__(self, address=('localhost', 514), facility=1)
(Constructor)

 

Initialize a handler.

If address is specified as a string, UNIX socket is used. If facility is not specified, LOG_USER is used.

Overrides: Filterer.__init__

encodePriority(self, facility, priority)

 

Encode the facility and priority. You can pass in strings or integers - if strings are passed, the facility_names and priority_names mapping dictionaries are used to convert them to integers.

close(self)

 

Closes the socket.

Overrides: Handler.close

mapPriority(self, levelName)

 

Map a logging level name to a key in the priority_names map. This is useful in two scenarios: when custom levels are being used, and in the case where you can't do a straightforward mapping by lowercasing the logging level name because of locale- specific issues (see SF #1524081).

emit(self, record)

 

Emit a record.

The record is formatted, and then sent to the syslog server. If exception information is present, it is NOT sent to the server.

Overrides: Handler.emit

Class Variable Details [hide private]

priority_names

Value:
{'alert': 1,
 'crit': 2,
 'critical': 2,
 'debug': 7,
 'emerg': 0,
 'err': 3,
 'error': 3,
 'info': 6,
...

facility_names

Value:
{'auth': 4,
 'authpriv': 10,
 'cron': 9,
 'daemon': 3,
 'kern': 0,
 'local0': 16,
 'local1': 17,
 'local2': 18,
...

priority_map

Value:
{'CRITICAL': 'critical',
 'DEBUG': 'debug',
 'ERROR': 'error',
 'INFO': 'info',
 'WARNING': 'warning'}