Home | Trees | Index | Help |
|
---|
Module netsyslog :: Class Logger |
|
object
--+
|
Logger
Send log messages to syslog servers.
The Logger class provides two different methods for sending log messages. The first approach (thelog
method) is suitable for creating new log messages from within a normal
application. The second (the send_packet
method) is designed for use in
circumstances where you need full control over the contents of the syslog
packet.
Method Summary | |
---|---|
__init__(self)
| |
Add hostname to the list of hosts that will receive packets. | |
Send the message text to all registered hosts. | |
Remove hostname from the list of hosts that will receive packets. | |
Send a Packet object to all registered hosts. | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Class Variable Summary | |
---|---|
int |
PORT = 514 |
Method Details |
---|
add_host(self, hostname)Add hostname to the list of hosts that will receive packets. Can be a hostname or an IP address. Note that if the hostname cannot be resolved calls tolog or send_packet will take a long time to
return.
|
log(self, facility, level, text, pid=False)Send the message text to all registered hosts. The facility and level will be used to create the packet's PRI part. The HEADER will be automatically determined from the current time and hostname. The MSG will be set from the running program's name and the text parameter. This is the simplest way to use netsyslog, creating log messages containing the current time, hostname, program name, etc. This is how you do it:logger = netsyslog.Logger() logger.add_host("localhost") logger.log(syslog.LOG_USER, syslog.LOG_INFO, "Hello World")If pid is True the process ID will be prepended to the text parameter, enclosed in square brackets and followed by a colon. |
remove_host(self, hostname)Remove hostname from the list of hosts that will receive packets. |
send_packet(self, packet)Send a log as you need to construct your own Packet
object beforehand, but it does give you full control over the contents
of the packet:
pri = netsyslog.PriPart(syslog.LOG_USER, syslog.LOG_INFO) header = netsyslog.HeaderPart("Jun 1 18:34:03", "myhost") msg = netsyslog.MsgPart("myprog", "Hello World", mypid) packet = netsyslog.Packet(pri, header, msg) logger = netsyslog.Logger() logger.add_host("localhost") logger.send_packet(packet) |
Class Variable Details |
---|
PORT
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Jul 15 11:57:30 2005 | http://epydoc.sf.net |