velosurf.util
Class Logger

java.lang.Object
  extended by velosurf.util.Logger

public class Logger
extends java.lang.Object

This class is the logger used by velosurf.

Author:
Claude Brisson

Field Summary
private static int asyncLimit
          max number of lines to log in asynchronous mode.
(package private) static java.io.StringWriter asyncLog
          asynchronous log used at start.
private static boolean captureStderr
          whether the logger captures stderr.
private static boolean captureStdout
          whether the logger captures stdout.
static int DEBUG_ID
          debug messages loglevel.
private static boolean displayTimestamps
          whether to display timestamps.
static int ERROR_ID
          error messages loglevel.
static int FATAL_ID
          fatal messages loglevel.
(package private) static java.text.SimpleDateFormat format
          date format for timestamps.
static int INFO_ID
          info messages loglevel.
private static boolean initialized
          Did someone give me an otput writer?
(package private) static int lines
           
(package private) static java.io.PrintWriter log
          log output printwriter.
private static int logLevel
          Current log level.
private static MailNotifier notifier
           
private static int notifLevel
           
private static boolean notify
           
(package private) static java.io.PrintStream oldStderr
          stderr old value.
(package private) static java.io.PrintStream oldStdout
          stdout old value.
static int TRACE_ID
          trace messages loglevel.
static int WARN_ID
          warn messages loglevel.
 
Constructor Summary
Logger()
           
 
Method Summary
static void debug(java.lang.String s)
          logs a debug string.
static void dumpStack()
          dumps the current stack.
static void enableNotifications(boolean enable)
           
static void error(java.lang.String s)
          logs an error string.
static void fatal(java.lang.String s)
          logs a fatal error string.
private static void flushAsyncLog()
          flush the asynchronous log in the output writer.
static int getLogLevel()
          Gets the current log level.
static int getNotificationLevel()
           
static boolean getNotifierEnabled()
           
static java.io.PrintWriter getWriter()
          get the output writer.
private static java.lang.String header()
          returns "Velosurf ".
static void info(java.lang.String s)
          logs an info string.
static boolean isInitialized()
          queries the initialized state.
static void log(int level, java.lang.String s)
          log a string using a verbose level.
private static void log(java.lang.String s)
          logs a string.
static void log(java.lang.String s, java.lang.Throwable e)
          logs an exception with a string.
static void log(java.lang.Throwable e)
          log an exception.
static void log2File(java.lang.String file)
          log to file.
static void log2Stderr()
          log to stderr.
static void log2Stdout()
          log to stdout.
static void setDisplayTimestamps(boolean timestamps)
          whether to display timestamps.
static void setLogLevel(int logLevel)
          Sets the log level.
static void setNotificationLevel(int level)
           
static void setNotificationParams(java.lang.String host, java.lang.String sender, java.lang.String recipient)
           
static void setWriter(java.lang.Object out)
          set the output writer.
static void startCaptureStderr()
          redirects stderr towards the output writer.
static void startCaptureStdout()
          redirects stdout towards output writer.
static void stopCaptureStderr()
          stops redirecting stderr.
static void stopCaptureStdout()
          stop redirecting stdout.
static void trace(java.lang.String s)
          logs a tracing string.
static void warn(java.lang.String s)
          logs a warning string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_ID

public static final int TRACE_ID
trace messages loglevel.

See Also:
Constant Field Values

DEBUG_ID

public static final int DEBUG_ID
debug messages loglevel.

See Also:
Constant Field Values

INFO_ID

public static final int INFO_ID
info messages loglevel.

See Also:
Constant Field Values

WARN_ID

public static final int WARN_ID
warn messages loglevel.

See Also:
Constant Field Values

ERROR_ID

public static final int ERROR_ID
error messages loglevel.

See Also:
Constant Field Values

FATAL_ID

public static final int FATAL_ID
fatal messages loglevel.

See Also:
Constant Field Values

logLevel

private static int logLevel
Current log level.


displayTimestamps

private static boolean displayTimestamps
whether to display timestamps.


captureStdout

private static boolean captureStdout
whether the logger captures stdout.


captureStderr

private static boolean captureStderr
whether the logger captures stderr.


asyncLimit

private static int asyncLimit
max number of lines to log in asynchronous mode.


initialized

private static boolean initialized
Did someone give me an otput writer?


format

static java.text.SimpleDateFormat format
date format for timestamps.


asyncLog

static java.io.StringWriter asyncLog
asynchronous log used at start.


log

static java.io.PrintWriter log
log output printwriter.


oldStdout

static java.io.PrintStream oldStdout
stdout old value.


oldStderr

static java.io.PrintStream oldStderr
stderr old value.


lines

static int lines

notifier

private static MailNotifier notifier

notifLevel

private static int notifLevel

notify

private static boolean notify
Constructor Detail

Logger

public Logger()
Method Detail

setLogLevel

public static void setLogLevel(int logLevel)
Sets the log level.

Parameters:
logLevel - log level

setDisplayTimestamps

public static void setDisplayTimestamps(boolean timestamps)
whether to display timestamps.

Parameters:
timestamps -

getLogLevel

public static int getLogLevel()
Gets the current log level.

Returns:
the current log level

log

private static void log(java.lang.String s)
logs a string.

Parameters:
s - string

log

public static void log(java.lang.String s,
                       java.lang.Throwable e)
logs an exception with a string.

Parameters:
s - string
e - exception

log

public static void log(java.lang.Throwable e)
log an exception.

Parameters:
e - exception

log

public static void log(int level,
                       java.lang.String s)
log a string using a verbose level.

Parameters:
level - verbose level
s - string to log

trace

public static void trace(java.lang.String s)
logs a tracing string.

Parameters:
s - tracing string

debug

public static void debug(java.lang.String s)
logs a debug string.

Parameters:
s - debug string

info

public static void info(java.lang.String s)
logs an info string.

Parameters:
s - info string

warn

public static void warn(java.lang.String s)
logs a warning string.

Parameters:
s - warning string

error

public static void error(java.lang.String s)
logs an error string.

Parameters:
s - error string

fatal

public static void fatal(java.lang.String s)
logs a fatal error string.

Parameters:
s - fatal error string

getWriter

public static java.io.PrintWriter getWriter()
get the output writer.

Returns:
writer

setWriter

public static void setWriter(java.lang.Object out)
set the output writer.

Parameters:
out - PrintWriter or Writer or OutputStream

startCaptureStdout

public static void startCaptureStdout()
redirects stdout towards output writer.


stopCaptureStdout

public static void stopCaptureStdout()
stop redirecting stdout.


startCaptureStderr

public static void startCaptureStderr()
redirects stderr towards the output writer.


stopCaptureStderr

public static void stopCaptureStderr()
stops redirecting stderr.


log2Stdout

public static void log2Stdout()
log to stdout.


log2Stderr

public static void log2Stderr()
log to stderr.


log2File

public static void log2File(java.lang.String file)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
log to file.

Throws:
java.io.FileNotFoundException
java.io.IOException

header

private static java.lang.String header()
returns "Velosurf ".

Returns:
return the header

flushAsyncLog

private static void flushAsyncLog()
flush the asynchronous log in the output writer.


isInitialized

public static boolean isInitialized()
queries the initialized state.


dumpStack

public static void dumpStack()
dumps the current stack.


setNotificationParams

public static void setNotificationParams(java.lang.String host,
                                         java.lang.String sender,
                                         java.lang.String recipient)

setNotificationLevel

public static void setNotificationLevel(int level)

getNotificationLevel

public static int getNotificationLevel()

enableNotifications

public static void enableNotifications(boolean enable)

getNotifierEnabled

public static boolean getNotifierEnabled()


~ooOoo~