utils
Enum Log

java.lang.Object
  extended by java.lang.Enum<Log>
      extended by utils.Log
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Log>

public enum Log
extends java.lang.Enum<Log>

Common application message logger facility (static implementation)

Author:
Mikica B Kocic

Nested Class Summary
static interface Log.AttentionContext
           
 
Enum Constant Summary
ALL
          Log all messages
ATTN
          Log attn messages
AUDIO
          Log audio messages
DEBUG
          Log debug messages
ERROR
          Log errors
INFO
          Log information
PDU
          Log binary PDUs
TRACE
          Log program trace
WARN
          Log warnings
VERB
          Log verbose PDUs
 
Field Summary
static Log.AttentionContext attn
          Instance of the interface for attention messages
private  java.lang.String desc
          Log channel description
static java.io.PrintStream err
          Print stream for error messages
private  int mask
          Log channel bitmap
static java.io.PrintStream out
          Print stream for standard messages
private static Log showChannels
          Current channels to be logged.
 
Method Summary
static void attn(java.lang.String string)
          Logs a attention message.
static void audio(java.lang.String string)
          Logs a audio message.
static void debug(java.lang.String string)
          Logs a debug message.
static void error(java.lang.String string)
          Logs a warning message.
static java.lang.String EscapeHTML(java.lang.String str)
          Escapes HTML reserved characters (as we are logging HTML tagged messages) It also replaces form-feed characters with HTML line-breaks.
static void exception(Log channel, java.lang.Exception ex)
          Returns current callee's name of the method, file, location and description of the exception.
static void info(java.lang.String string)
          Logs a informational message.
static boolean isEnabled(Log channel)
          Returns if log channel is enabled
static java.lang.String now()
          Gets current time stamp -- date and time in ISO format
static java.lang.String nowDate()
          Gets current time stamp -- date only
static java.lang.String nowMillis()
          Gets current time stamp -- time with milliseconds
static java.lang.String nowTime()
          Gets current time stamp -- time only
static void pdu(java.lang.String string)
          Logs a protocol data unit
private static void println(Log channel, java.lang.String message)
          Logs message with prefix and time-stamp
static void setEnabled(Log channel, boolean on)
          Enables/disables the Log channel
static java.lang.String toHex(byte[] array)
          Converts a byte array into a hex string.
static java.lang.String toHex(byte[] array, int length, java.lang.String separator)
          Converts a byte array into a hex string, using the specified separator.
static java.lang.String toHex(byte[] array, java.lang.String separator)
          Converts a byte array into a hex string, using the specified separator.
static void trace(java.lang.String string)
          Logs a program trace message.
static Log valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static Log[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
static void warn(java.lang.String string)
          Logs a warning message.
static void verb(java.lang.String string)
          Logs a verbose message.
static void where()
          Prints where this message was called from, via a stack trace.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

ALL

public static final Log ALL
Log all messages


AUDIO

public static final Log AUDIO
Log audio messages


VERB

public static final Log VERB
Log verbose PDUs


PDU

public static final Log PDU
Log binary PDUs


DEBUG

public static final Log DEBUG
Log debug messages


ATTN

public static final Log ATTN
Log attn messages


TRACE

public static final Log TRACE
Log program trace


INFO

public static final Log INFO
Log information


WARN

public static final Log WARN
Log warnings


ERROR

public static final Log ERROR
Log errors

Field Detail

mask

private int mask
Log channel bitmap


desc

private java.lang.String desc
Log channel description


showChannels

private static Log showChannels
Current channels to be logged. By default only the Error channel is enabled.


out

public static java.io.PrintStream out
Print stream for standard messages


err

public static java.io.PrintStream err
Print stream for error messages


attn

public static Log.AttentionContext attn
Instance of the interface for attention messages

Method Detail

values

public static Log[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Log c : Log.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Log valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

setEnabled

public static void setEnabled(Log channel,
                              boolean on)
Enables/disables the Log channel


isEnabled

public static boolean isEnabled(Log channel)
Returns if log channel is enabled


println

private static void println(Log channel,
                            java.lang.String message)
Logs message with prefix and time-stamp


error

public static void error(java.lang.String string)
Logs a warning message.


warn

public static void warn(java.lang.String string)
Logs a warning message.


info

public static void info(java.lang.String string)
Logs a informational message.


debug

public static void debug(java.lang.String string)
Logs a debug message.


attn

public static void attn(java.lang.String string)
Logs a attention message.


trace

public static void trace(java.lang.String string)
Logs a program trace message.


pdu

public static void pdu(java.lang.String string)
Logs a protocol data unit


verb

public static void verb(java.lang.String string)
Logs a verbose message.


audio

public static void audio(java.lang.String string)
Logs a audio message.


where

public static void where()
Prints where this message was called from, via a stack trace.


exception

public static void exception(Log channel,
                             java.lang.Exception ex)
Returns current callee's name of the method, file, location and description of the exception.


toHex

public static java.lang.String toHex(byte[] array,
                                     int length,
                                     java.lang.String separator)
Converts a byte array into a hex string, using the specified separator.

Parameters:
array - The byte array
length - The length to print
separator - The separator (may be null)
Returns:
The hex character string

toHex

public static java.lang.String toHex(byte[] array,
                                     java.lang.String separator)
Converts a byte array into a hex string, using the specified separator.


toHex

public static java.lang.String toHex(byte[] array)
Converts a byte array into a hex string.


nowDate

public static java.lang.String nowDate()
Gets current time stamp -- date only


nowTime

public static java.lang.String nowTime()
Gets current time stamp -- time only


now

public static java.lang.String now()
Gets current time stamp -- date and time in ISO format


nowMillis

public static java.lang.String nowMillis()
Gets current time stamp -- time with milliseconds


EscapeHTML

public static java.lang.String EscapeHTML(java.lang.String str)
Escapes HTML reserved characters (as we are logging HTML tagged messages) It also replaces form-feed characters with HTML line-breaks.