Main: Whitepaper FAQ Examples JavaDoc Classloader Performance
Protomatter Software v1.1.8

com.protomatter.syslog
Class SimpleSyslogTextFormatter

java.lang.Object
  |
  +--com.protomatter.syslog.SimpleSyslogTextFormatter
All Implemented Interfaces:
SyslogTextFormatter
Direct Known Subclasses:
HTMLSyslogTextFormatter, 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.
 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()
          Get the width of the channel field.
 int getClassWidth()
          Get the width of the caller class name field.
 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.
 java.lang.String getHostname(java.net.InetAddress host)
           
 int getHostWidth()
          Get the width of the hostname field.
 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 getShowCaller()
          Get wether we should show the caller name in the output.
 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()
          Get the width of the thread field.
protected  void justify(java.lang.StringBuffer out, java.lang.StringBuffer in, int width)
          Justify text to given width in the buffer.
protected  void justify(java.lang.StringBuffer out, java.lang.String in, int width)
          Justify text to given width in the buffer.
 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)
          Set the width of the channel field.
 void setClassWidth(int classWidth)
          Set the width of the caller class name field.
 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)
          Set the width of the hostname field.
 void setShowCaller(boolean showCaller)
          Set wether we should show the caller name in the output.
 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)
          Set the width of the thread field.
protected  java.lang.String trimFromLastPeriod(java.lang.String s)
          Trim a string after the last "." (dot).
protected  void trimFromLastPeriod(java.lang.StringBuffer b, java.lang.String s, int width)
          Given something like "foo.bar.Baz" this will return "Baz".
protected  void trimFromLastPeriod(java.lang.StringBuffer b, java.lang.String className, java.lang.String method, int line, 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

public 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

public 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.

setShowCaller

public void setShowCaller(boolean showCaller)
Set wether we should show the caller name in the output.

getShowCaller

public boolean getShowCaller()
Get wether we should show the caller 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 void trimFromLastPeriod(java.lang.StringBuffer b,
                                  java.lang.String className,
                                  java.lang.String method,
                                  int line,
                                  int width)
Given something like "foo.bar.Baz" this will return "Baz".

trimFromLastPeriod

protected java.lang.String trimFromLastPeriod(java.lang.String s)
Trim a string after the last "." (dot).

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()
Get the width of the caller class name field.

setClassWidth

public void setClassWidth(int classWidth)
Set the width of the caller class name field.

getHostWidth

public int getHostWidth()
Get the width of the hostname field.

setHostWidth

public void setHostWidth(int hostWidth)
Set the width of the hostname field.

getChannelWidth

public int getChannelWidth()
Get the width of the channel field.

setChannelWidth

public void setChannelWidth(int channelWidth)
Set the width of the channel field.

getThreadWidth

public int getThreadWidth()
Get the width of the thread field.

setThreadWidth

public void setThreadWidth(int threadWidth)
Set the width of the thread field.

justify

protected void justify(java.lang.StringBuffer out,
                       java.lang.StringBuffer in,
                       int width)
Justify text to given width in the buffer.

justify

protected void justify(java.lang.StringBuffer out,
                       java.lang.String in,
                       int width)
Justify text to given width in the buffer.

Protomatter Software v1.1.8
Copyright 1998-2002 Nate Sammons

Protomatter Software v1.1.8 http://protomatter.sourceforge.net/1.1.8