util
Class DatagramLog

java.lang.Object
  extended by com.protomatter.syslog.BasicLogger
      extended by util.DatagramLog
All Implemented Interfaces:
com.protomatter.syslog.Syslogger

public class DatagramLog
extends com.protomatter.syslog.BasicLogger

This syslog facilitiy ties into a running syslog-server. It sends datagram packages to the syslog-server, which may reside on a remote machine.

This class joins the syslog client with the protomatter syslog-facilities. It expands the protomatter BasicLogger class and loosely ties into the syslog client.


Nested Class Summary
static class DatagramLog.Test
          Test purpose only.
 
Field Summary
private  InetAddress boundAddress
           
private  int facility
           
private  String hostName
           
private  int portNum
           
private  DatagramSocket socket
           
 
Fields inherited from class com.protomatter.syslog.BasicLogger
formatter, policy, realPolicy
 
Constructor Summary
DatagramLog()
          Creates a Syslog object instance, targeted for the UNIX host with the hostname 'hostname' on the syslog port 'port'.
DatagramLog(String hostname, int port, int fac)
          Creates a Syslog object instance, targeted for the UNIX host with the hostname 'hostname' on the syslog port 'port'.
 
Method Summary
private  void cleanup()
           
 void flush()
          Flush the stream.
 String getFacility()
           
 String getHost()
           
 int getPort()
           
private  void initialize()
           
 void log(com.protomatter.syslog.SyslogMessage message)
          Write a log message.
private  void resolve()
           
 void setFacility(String facname)
           
 void setHost(String hname)
           
 void setPort(int port)
           
 void shutdown()
          Clean up and prepare for shutdown.
private  void syslog(InetAddress addr, int port, int fac, int pri, String msg)
          Use this method to log your syslog messages.
 
Methods inherited from class com.protomatter.syslog.BasicLogger
formatLogEntry, getName, getPolicy, getTextFormatter, isSuspended, mightLog, resetDateFormat, resume, setName, setPolicy, setTextFormatter, shouldLog, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hostName

private String hostName

portNum

private int portNum

boundAddress

private InetAddress boundAddress

socket

private DatagramSocket socket

facility

private int facility
Constructor Detail

DatagramLog

public DatagramLog()
Creates a Syslog object instance, targeted for the UNIX host with the hostname 'hostname' on the syslog port 'port'. The only flags recognized are 'LOG_PERROR', which will log the message to Java's 'System.err'.


DatagramLog

public DatagramLog(String hostname,
                   int port,
                   int fac)
Creates a Syslog object instance, targeted for the UNIX host with the hostname 'hostname' on the syslog port 'port'. The only flags recognized are 'LOG_PERROR', which will log the message to Java's 'System.err'.

Method Detail

setFacility

public void setFacility(String facname)

getFacility

public String getFacility()

setHost

public void setHost(String hname)

getHost

public String getHost()

setPort

public void setPort(int port)

getPort

public int getPort()

resolve

private void resolve()

initialize

private void initialize()

syslog

private void syslog(InetAddress addr,
                    int port,
                    int fac,
                    int pri,
                    String msg)
Use this method to log your syslog messages. The facility and level are the same as their UNIX counterparts, and the Syslog class provides constants for these fields. The msg is what is actually logged.


log

public void log(com.protomatter.syslog.SyslogMessage message)
Write a log message.

Specified by:
log in interface com.protomatter.syslog.Syslogger
Specified by:
log in class com.protomatter.syslog.BasicLogger

cleanup

private void cleanup()

shutdown

public void shutdown()
Clean up and prepare for shutdown.

Specified by:
shutdown in interface com.protomatter.syslog.Syslogger
Specified by:
shutdown in class com.protomatter.syslog.BasicLogger

flush

public void flush()
Flush the stream. Empty method.

Specified by:
flush in interface com.protomatter.syslog.Syslogger
Specified by:
flush in class com.protomatter.syslog.BasicLogger