autohit.common
Class AutohitLogDrain

java.lang.Object
  extended byautohit.common.AutohitLogDrain
All Implemented Interfaces:
Drain
Direct Known Subclasses:
AutohitLogDrainDefault, AutohitLogDrainRouting

public abstract class AutohitLogDrain
extends java.lang.Object
implements Drain

An abstract logging formatter for Autohit Tools. It will try to log anything that has a String in the atom. You can route Atom.senderIDs to different output streams.

The subclasses need to implement a setWriter() and initchain().

A pretty flag tells the formatter to keep the lines under 80 characters, applying wrapping where possible. TRUE means pretty. The default is FALSE. It will use the line.separator property to put a return on the wrapped lines.

NOT STAMPED 0123456789...............{79} IINNNN:tttttttttt......t[EOL] :tttttttttt......t[EOL] [ 7 ][ 69 ]

STAMPED (with default formatter) We will reserve 4 extra spacers that an overloading formatter can use. 012345678901234567890123456789...............{79} IINNNN[DD:HHMMSS]tttttttttt.................t[EOL] ]tttttttttt.................t[EOL] [ 6 ][9+3extra ][ 54 ] [18] + [61] = 79 Cs0000:223600: XMLCompiler: Software Detected Fault: SAXException mad e it out of the builder.

Version:
1.0 Version History EPG - Rewrite - 27Apr03
Author:
Erich P. Gatejen

Field Summary
protected  java.io.Writer myWriter
           
 
Constructor Summary
AutohitLogDrain()
          Default constructor You must init() the drain before it is valid.
 
Method Summary
abstract  void discardWriter(java.lang.String id)
          The subclass uses this to discard the Writer.
protected  java.lang.String form(java.lang.String s)
          Form this string into an entry.
 void init(java.io.OutputStream os)
          Call this to initialize.
 void init(java.io.OutputStream os, int linesize)
          Call this to initialize.
abstract  void initchain()
          The subclass should implement this to do any initialization.
 java.lang.String numericFormatter(int n)
          This formats the the numeric into a four digit string.
 Receipt post(Atom a)
          Post an item Don't care about receipts
 void setLineLimit(int limit)
          Set the max number characters printed per line
 void setPrettyFlag(boolean b)
          This sets the pretty flag.
 void setTimestampFlag(boolean b)
          This sets the timestamp flag.
abstract  void setWriter(java.lang.String id)
          The subclass uses this to set the Writer.
 java.lang.String timestampFormatter(long stamp)
          This formats the timestamp for stamped entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myWriter

protected java.io.Writer myWriter
Constructor Detail

AutohitLogDrain

public AutohitLogDrain()
Default constructor You must init() the drain before it is valid.

Method Detail

post

public Receipt post(Atom a)
             throws ChannelException
Post an item Don't care about receipts

Specified by:
post in interface Drain
Parameters:
a - An atom containing the posted data
Returns:
null -- always
Throws:
ChannelException

numericFormatter

public java.lang.String numericFormatter(int n)
This formats the the numeric into a four digit string.

Parameters:
n - numeric value
Returns:
a string representation of the numeric

timestampFormatter

public java.lang.String timestampFormatter(long stamp)
This formats the timestamp for stamped entries. You can overload this if you want a different format. This one will do [DD:HHMMSS]

Parameters:
stamp - timestamp in milliseconds. This formatter assumes it is the unmodified system time.
Returns:
a string representation of the timestamp

form

protected java.lang.String form(java.lang.String s)
Form this string into an entry.

Parameters:
s - string
Returns:
formed string

setPrettyFlag

public void setPrettyFlag(boolean b)
This sets the pretty flag. This will try and keep log lines at under 80 characters, applying wrapping where possible. TRUE means pretty. The default is FALSE. Not syncronized. It will take effect on the next log write.

Parameters:
b -

setTimestampFlag

public void setTimestampFlag(boolean b)
This sets the timestamp flag. This will tell it to timestamp the entries. TRUE means do it. The default is FALSE. Not syncronized. It will take effect on the next log write.

Parameters:
b -

setLineLimit

public void setLineLimit(int limit)
Set the max number characters printed per line

Parameters:
limit - the number of characters printed in a line

setWriter

public abstract void setWriter(java.lang.String id)
                        throws java.lang.Exception
The subclass uses this to set the Writer. the Writer is the field myWriter.

Parameters:
id -
Throws:
java.lang.Exception

discardWriter

public abstract void discardWriter(java.lang.String id)
                            throws java.lang.Exception
The subclass uses this to discard the Writer. It says this id isn't being used anymore.

Parameters:
id -
Throws:
java.lang.Exception

initchain

public abstract void initchain()
The subclass should implement this to do any initialization.


init

public void init(java.io.OutputStream os)
          throws java.lang.Exception
Call this to initialize. Need to provide at least a default Stream.

Throws:
java.lang.Exception

init

public void init(java.io.OutputStream os,
                 int linesize)
          throws java.lang.Exception
Call this to initialize. Need to provide at least a default Stream.

Throws:
java.lang.Exception


Test.