water.util
Class Log

java.lang.Object
  extended by water.util.Log

public abstract class Log
extends java.lang.Object

Log for H2O. This class should be loaded before we start to print as it wraps around System.{out,err}. There are three kinds of message: INFO, WARN and ERRR, for general information, events that look wrong, and runtime exceptions. WARN messages and uncaught exceptions are printed on Standard output. Some INFO messages are also printed on standard output. Many more messages are printed to the log file in the ice directory and to the K/V store. Messages can come from a number of subsystems, Sys.RANDF for instance denotes the Random forest implementation. Subsystem names are five letter mnemonics to keep formatting nicely even. To print messages from a subsystem to the log file, set a property on the command line -Dlog.RANDF=true -Dlog.RANDF=false // turn off or call the API function Log.setFlag(Sys.RANDF); Log.unsetFlag(Sys.RANDF); // turn off OOME: when the VM is low on memory, OutOfMemoryError can be thrown in the logging framework while it is trying to print a message. In this case the first message that fails is recorded for later printout, and a number of messages can be discarded. The framework will attempt to print the recorded message later, and report the number of dropped messages, but this done in a best effort and lossy manner. Basically when an OOME occurs during logging, no guarantees are made about the messages.


Nested Class Summary
static class Log.LogStr
           
static interface Log.Tag
          Tags for log messages
static class Log.Wrapper
           
 
Field Summary
static boolean _dontDie
           
static Log.Tag.Kind[] KINDS
           
static Key LOG_KEY
          Key for the log in the KV store
static long PID
          Some guess at the process ID.
static Log.Tag.Sys[] SYSS
           
 
Constructor Summary
Log()
           
 
Method Summary
static void debug(Log.Tag.Sys t, java.lang.Object... objects)
          Log a debug message to the log file and the store if the subsystem's flag is set.
static void debug(java.lang.Object... objects)
          Log a debug message to the log file and the store if the subsystem's flag is set.
static void die(java.lang.String s)
           
static void err(Log.Tag.Sys t, java.lang.String msg)
          Record a message to the log file and store.
static
<T extends java.lang.Throwable>
T
err(Log.Tag.Sys t, java.lang.String msg, T exception)
          Record an exception to the log file and store.
static
<T extends java.lang.Throwable>
T
err(Log.Tag.Sys t, T exception)
          Record an exception to the log file and store.
static void err(java.lang.String msg)
          Record a message to the log file and store.
static
<T extends java.lang.Throwable>
T
err(java.lang.String msg, T exception)
          Record an exception to the log file and store.
static
<T extends java.lang.Throwable>
T
err(T exception)
          Record an exception to the log file and store.
static java.lang.RuntimeException errRTExcept(java.lang.Throwable exception)
          Record an exception to the log file and store and return a new RuntimeException that wraps around the exception.
static java.lang.String fixedLength(java.lang.String s, int length)
          Log a debug message to the log file and the store if the subsystem's flag is set.
static boolean flag(Log.Tag.Sys t)
          Check if a subsystem will print debug message to the LOG file
static java.lang.String getLogDir()
           
static java.lang.String getLogPathFileName()
           
static void info(Log.Tag.Sys t, java.lang.Object... objects)
          Log an information message to standard out, the log file and the store.
static void info(java.lang.Object... objects)
          Log an information message to standard out, the log file and the store.
static void log(java.io.File file, java.io.PrintStream stream)
           
static void main(java.lang.String[] args)
           
static java.lang.String padRight(java.lang.String stringToPad, int size)
           
static void POST(int n, java.lang.Exception e)
           
static void POST(int n, java.lang.String s)
          POST stands for "Power on self test".
static void setFlag(Log.Tag.Sys t)
          Set the debug flag.
static void unsetFlag(Log.Tag.Sys t)
          Unset the debug flag.
static java.io.PrintStream unwrap(java.io.PrintStream stream)
           
static void unwrap(java.io.PrintStream stream, java.lang.String s)
          Print a message to the stream without the logging information.
static java.lang.Throwable warn(Log.Tag.Sys t, java.lang.String msg)
          Log a warning to standard out, the log file and the store.
static
<T extends java.lang.Throwable>
T
warn(Log.Tag.Sys t, java.lang.String msg, T exception)
          Log a warning to standard out, the log file and the store.
static java.lang.Throwable warn(java.lang.String msg)
          Log a warning to standard out, the log file and the store.
static void wrap()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KINDS

public static final Log.Tag.Kind[] KINDS

SYSS

public static final Log.Tag.Sys[] SYSS

LOG_KEY

public static final Key LOG_KEY
Key for the log in the KV store


PID

public static final long PID
Some guess at the process ID.


_dontDie

public static boolean _dontDie
Constructor Detail

Log

public Log()
Method Detail

wrap

public static void wrap()

flag

public static boolean flag(Log.Tag.Sys t)
Check if a subsystem will print debug message to the LOG file


setFlag

public static void setFlag(Log.Tag.Sys t)
Set the debug flag.


unsetFlag

public static void unsetFlag(Log.Tag.Sys t)
Unset the debug flag.


getLogDir

public static java.lang.String getLogDir()

getLogPathFileName

public static java.lang.String getLogPathFileName()

err

public static <T extends java.lang.Throwable> T err(Log.Tag.Sys t,
                                                    java.lang.String msg,
                                                    T exception)
Record an exception to the log file and store.


err

public static void err(Log.Tag.Sys t,
                       java.lang.String msg)
Record a message to the log file and store.


err

public static <T extends java.lang.Throwable> T err(java.lang.String msg,
                                                    T exception)
Record an exception to the log file and store.


err

public static void err(java.lang.String msg)
Record a message to the log file and store.


err

public static <T extends java.lang.Throwable> T err(Log.Tag.Sys t,
                                                    T exception)
Record an exception to the log file and store.


err

public static <T extends java.lang.Throwable> T err(T exception)
Record an exception to the log file and store.


errRTExcept

public static java.lang.RuntimeException errRTExcept(java.lang.Throwable exception)
Record an exception to the log file and store and return a new RuntimeException that wraps around the exception.


warn

public static <T extends java.lang.Throwable> T warn(Log.Tag.Sys t,
                                                     java.lang.String msg,
                                                     T exception)
Log a warning to standard out, the log file and the store.


warn

public static java.lang.Throwable warn(Log.Tag.Sys t,
                                       java.lang.String msg)
Log a warning to standard out, the log file and the store.


warn

public static java.lang.Throwable warn(java.lang.String msg)
Log a warning to standard out, the log file and the store.


info

public static void info(Log.Tag.Sys t,
                        java.lang.Object... objects)
Log an information message to standard out, the log file and the store.


info

public static void info(java.lang.Object... objects)
Log an information message to standard out, the log file and the store.


debug

public static void debug(java.lang.Object... objects)
Log a debug message to the log file and the store if the subsystem's flag is set.


debug

public static void debug(Log.Tag.Sys t,
                         java.lang.Object... objects)
Log a debug message to the log file and the store if the subsystem's flag is set.


fixedLength

public static java.lang.String fixedLength(java.lang.String s,
                                           int length)
Log a debug message to the log file and the store if the subsystem's flag is set.


padRight

public static java.lang.String padRight(java.lang.String stringToPad,
                                        int size)

die

public static void die(java.lang.String s)

unwrap

public static void unwrap(java.io.PrintStream stream,
                          java.lang.String s)
Print a message to the stream without the logging information.


unwrap

public static java.io.PrintStream unwrap(java.io.PrintStream stream)

log

public static void log(java.io.File file,
                       java.io.PrintStream stream)
                throws java.lang.Exception
Throws:
java.lang.Exception

POST

public static void POST(int n,
                        java.lang.String s)
POST stands for "Power on self test". Stamp a POST code to /tmp. This is for bringup, when no logging or stdout I/O is reliable. (Especially when embedded, such as in hadoop mapreduce, for example.)

Parameters:
n - POST code.
s - String to emit.

POST

public static void POST(int n,
                        java.lang.Exception e)

main

public static void main(java.lang.String[] args)