Syslog White Paper FAQ Examples JavaDoc Classloader
Protomatter Software v1.1.7

com.protomatter.syslog
Class SimpleSyslogTextFormatter

java.lang.Object
  |
  +--com.protomatter.syslog.SimpleSyslogTextFormatter
All Implemented Interfaces:
SyslogTextFormatter
Direct Known Subclasses:
HTMLSyslogTextFormatter, JDK14SyslogTextFormatter, SyslogHTMLMailFormatter, Wl6SyslogTextFormatter, WlSyslogTextFormatter

public class SimpleSyslogTextFormatter
extends java.lang.Object
implements SyslogTextFormatter

A simple log entry formatter. This class is used by several of the included Syslogger implementations to format their log entries.

See Also:
XML configuration class

Constructor Summary
SimpleSyslogTextFormatter()
          Default constructor.
 
Method Summary
protected  char[] formatDate(long theDate)
          Format the given date with the dateformat that's been set.
 void formatLogEntry(java.lang.StringBuffer b, SyslogMessage message)
          Format the given log entry.
protected  void formatLoggerClassName(java.lang.StringBuffer b, SyslogMessage message)
           
 void formatMessageDetail(java.lang.StringBuffer b, SyslogMessage message)
          Format the given log message's detail.
 int getChannelWidth()
           
 int getClassWidth()
           
 java.lang.String getDateFormat()
          Get the format for logging dates.
 int getDateFormatCacheTime()
          Get the number of milliseconds a date format should be cached.
 java.util.TimeZone getDateFormatTimezone()
          Get the timezone of the date format.
protected  java.lang.String getHostname(java.net.InetAddress host)
           
 int getHostWidth()
           
 java.lang.String getLogFooter()
          Get the log footer.
 java.lang.String getLogHeader()
          Get the log header.
protected  java.lang.Object[] getNextException(java.lang.Throwable t)
          Get the "next" exception in this series.
 boolean getShowChannel()
          Get wether we should show the channel name in the output.
 boolean getShowHostName()
          Get wether we should show the host name in the output.
 boolean getShowThreadName()
          Get wether we should show the thread name in the output.
protected  char[] getStringForLevel(int level)
           
 int getThreadWidth()
           
protected  void justify(java.lang.StringBuffer out, java.lang.StringBuffer in, int width)
           
protected  void justify(java.lang.StringBuffer out, java.lang.String in, int width)
           
 void resetDateFormat()
          Reset the formatDate(...) method so that it's guaranteed to not return a cached date string the next time it's called.
 void setChannelWidth(int channelWidth)
           
 void setClassWidth(int classWidth)
           
 void setDateFormat(java.lang.String format)
          Set the format for logging dates.
 void setDateFormatCacheTime(int cacheTime)
          Set the number of milliseconds a date format should be cached.
 void setDateFormatTimezone(java.util.TimeZone zone)
          Set the timezone of the date format.
 void setHostWidth(int hostWidth)
           
 void setShowChannel(boolean showChannel)
          Set wether we should show the channel name in the output.
 void setShowHostName(boolean showHostName)
          Set wether we should show the host name in the output.
 void setShowThreadName(boolean showThreadName)
          Set wether we should show the thread name in the output.
 void setThreadWidth(int threadWidth)
           
protected  java.lang.String trimFromLastPeriod(java.lang.String s)
           
protected  void trimFromLastPeriod(java.lang.StringBuffer b, java.lang.String s, int width)
          Given something like "foo.bar.Baz" this will return "Baz".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSyslogTextFormatter

public SimpleSyslogTextFormatter()
Default constructor.
Method Detail

formatLogEntry

public void formatLogEntry(java.lang.StringBuffer b,
                           SyslogMessage message)
Format the given log entry.
Specified by:
formatLogEntry in interface SyslogTextFormatter

formatLoggerClassName

protected void formatLoggerClassName(java.lang.StringBuffer b,
                                     SyslogMessage message)

formatMessageDetail

public void formatMessageDetail(java.lang.StringBuffer b,
                                SyslogMessage message)
Description copied from interface: SyslogTextFormatter
Format the given log message's detail.
Specified by:
formatMessageDetail in interface SyslogTextFormatter

getNextException

protected java.lang.Object[] getNextException(java.lang.Throwable t)
Get the "next" exception in this series. This method will look for a no-arg method on the given object that returns a subclass of throwable. It will skip the "fillInStackTrace" method. The return type is a two-element object array. The first element is the method name (or null) that was called to get the next exception, and the second element is the instance of the Throwable.

getStringForLevel

protected char[] getStringForLevel(int level)

getHostname

protected java.lang.String getHostname(java.net.InetAddress host)

setDateFormat

public void setDateFormat(java.lang.String format)
Set the format for logging dates.

getDateFormat

public java.lang.String getDateFormat()
Get the format for logging dates.

setShowHostName

public void setShowHostName(boolean showHostName)
Set wether we should show the host name in the output. If this is set to true and the hostname has not been set on Syslog yet, the Syslog.setLocalHostName() method is called.

getShowHostName

public boolean getShowHostName()
Get wether we should show the host name in the output.

setShowThreadName

public void setShowThreadName(boolean showThreadName)
Set wether we should show the thread name in the output.

getShowThreadName

public boolean getShowThreadName()
Get wether we should show the thread name in the output.

setShowChannel

public void setShowChannel(boolean showChannel)
Set wether we should show the channel name in the output.

getShowChannel

public boolean getShowChannel()
Get wether we should show the channel name in the output.

setDateFormatCacheTime

public void setDateFormatCacheTime(int cacheTime)
Set the number of milliseconds a date format should be cached. This is also the resolution of the timestamp in log entries. Default is 1000ms (1 second).

getDateFormatCacheTime

public int getDateFormatCacheTime()
Get the number of milliseconds a date format should be cached. This is also the resolution of the timestamp in log entries. Default is 1000ms (1 second).

setDateFormatTimezone

public void setDateFormatTimezone(java.util.TimeZone zone)
Set the timezone of the date format. Default is TimeZone.getDefault().

getDateFormatTimezone

public java.util.TimeZone getDateFormatTimezone()
Get the timezone of the date format.

formatDate

protected char[] formatDate(long theDate)
Format the given date with the dateformat that's been set. This will cache the date until it's been long enough for the date format cache time to have expired.
See Also:
setDateFormatCacheTime(int)

trimFromLastPeriod

protected void trimFromLastPeriod(java.lang.StringBuffer b,
                                  java.lang.String s,
                                  int width)
Given something like "foo.bar.Baz" this will return "Baz".

trimFromLastPeriod

protected java.lang.String trimFromLastPeriod(java.lang.String s)

resetDateFormat

public void resetDateFormat()
Reset the formatDate(...) method so that it's guaranteed to not return a cached date string the next time it's called.
Specified by:
resetDateFormat in interface SyslogTextFormatter

getLogHeader

public java.lang.String getLogHeader()
Get the log header. This simply returns an empty string.
Specified by:
getLogHeader in interface SyslogTextFormatter

getLogFooter

public java.lang.String getLogFooter()
Get the log footer. This simply returns an empty string.
Specified by:
getLogFooter in interface SyslogTextFormatter

getClassWidth

public int getClassWidth()

setClassWidth

public void setClassWidth(int classWidth)

getHostWidth

public int getHostWidth()

setHostWidth

public void setHostWidth(int hostWidth)

getChannelWidth

public int getChannelWidth()

setChannelWidth

public void setChannelWidth(int channelWidth)

getThreadWidth

public int getThreadWidth()

setThreadWidth

public void setThreadWidth(int threadWidth)

justify

protected void justify(java.lang.StringBuffer out,
                       java.lang.StringBuffer in,
                       int width)

justify

protected void justify(java.lang.StringBuffer out,
                       java.lang.String in,
                       int width)

Protomatter Software v1.1.7
Copyright 1998-2002 Nate Sammons

Protomatter Software v1.1.7 http://protomatter.sourceforge.net/1.1.7