de.enough.polish.log
Class LogEntry

java.lang.Object
  extended by de.enough.polish.log.LogEntry

public class LogEntry
extends Object

Contains one log entry.

Copyright (c) Enough Software 2005 - 2009

 history
        23-Apr-2005 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
 String className
           
 String exception
           
 String level
           
 int lineNumber
           
 String message
           
 String thread
           
 long time
           
 
Constructor Summary
  LogEntry(String className, int lineNumber, long time, String level, String message, String exception)
          Creates a new log entry,
protected LogEntry(String className, int lineNumber, long time, String level, String message, String exception, String threadName)
          Creates a new log entry,
 
Method Summary
 String getMessage()
          Retrieves the message of this entry
static LogEntry newLogEntry(byte[] data)
          Reads a new log entry from the given input stream
static LogEntry newLogEntry(DataInputStream in)
          Reads a new log entry from the given input stream
 byte[] toByteArray()
          Writes the data into a byte buffer.
 String toString()
          Converts the entry into a log message.
 void write(DataOutputStream out)
          Writes this log entry to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

className

public final String className

time

public final long time

level

public final String level

message

public final String message

lineNumber

public final int lineNumber

exception

public final String exception

thread

public final String thread
Constructor Detail

LogEntry

public LogEntry(String className,
                int lineNumber,
                long time,
                String level,
                String message,
                String exception)
Creates a new log entry,

Parameters:
className - the name of the class
lineNumber - the line number within the class
time - the time of the log event
level - the level, e.g. "debug" or "info"
message - the message
exception - the exception message, if any

LogEntry

protected LogEntry(String className,
                   int lineNumber,
                   long time,
                   String level,
                   String message,
                   String exception,
                   String threadName)
Creates a new log entry,

Parameters:
className - the name of the class
lineNumber - the line number within the class
time - the time of the log event
level - the level, e.g. "debug" or "info"
message - the message
exception - the exception message, if any
threadName - the name of the current thread, always null on CLDC 1.0 devices
Method Detail

toByteArray

public byte[] toByteArray()
                   throws IOException
Writes the data into a byte buffer.

Returns:
a byte array containing the data
Throws:
IOException - when the data could not be written

toString

public String toString()
Converts the entry into a log message.

Overrides:
toString in class Object
Returns:
the String representation of this log entry

write

public void write(DataOutputStream out)
           throws IOException
Writes this log entry to the given output stream.

Parameters:
out - the output to which this entry should be writen.
Throws:
IOException - when the data could not be written

newLogEntry

public static LogEntry newLogEntry(byte[] data)
                            throws IOException
Reads a new log entry from the given input stream

Parameters:
data - the data
Returns:
a new log entry instance
Throws:
IOException - when the data could not be read

newLogEntry

public static LogEntry newLogEntry(DataInputStream in)
                            throws IOException
Reads a new log entry from the given input stream

Parameters:
in - the input from which the data is read
Returns:
a new log entry instance
Throws:
IOException - when the data could not be read

getMessage

public String getMessage()
Retrieves the message of this entry

Returns:
the message along with the exception, if there is any.