edu.stanford.nlp.util.logging
Class RedwoodConfiguration

java.lang.Object
  extended by edu.stanford.nlp.util.logging.RedwoodConfiguration

public class RedwoodConfiguration
extends Object

A class which encapsulates configuration settings for Redwood. The class operates on the builder model; that is, you can chain method calls.

Author:
Gabor Angeli (angeli at cs.stanford)

Constructor Summary
protected RedwoodConfiguration()
          Private constructor to prevent use of "new RedwoodConfiguration()"
 
Method Summary
 void apply()
          Apply this configuration to Redwood
static void apply(Properties props)
          Parses a properties file and applies it immediately to Redwood
 RedwoodConfiguration captureStderr()
          Capture stderr and route them through Redwood
 RedwoodConfiguration captureStdout()
          Capture stdout and route them through Redwood
 RedwoodConfiguration captureStreams()
          Capture stdout and stderr and route them through Redwood
 RedwoodConfiguration clear()
          Clear any custom configurations to Redwood
 RedwoodConfiguration collapseApproximate()
          Collapse repeated records, using an approximate notion of equality (i.e.
 RedwoodConfiguration collapseExact()
          Collapse repeated records, using exact string match on the record.
 RedwoodConfiguration collapseNone()
          Do not collapse repeated records
 RedwoodConfiguration console()
          Add a console pipeline to the Redwood handler tree, Calling this multiple times will result in messages being printed multiple times.
static RedwoodConfiguration current()
          The current Redwood configuration; this is used to make incremental changes to an existing custom configuration.
static RedwoodConfiguration empty()
          An empty Redwood configuration.
 RedwoodConfiguration file(String file)
          Add a file pipeline to the Redwood handler tree.
 RedwoodConfiguration handler(LogRecordHandler parent, LogRecordHandler child)
          Add a handler to as a child of an existing parent
 RedwoodConfiguration hideChannels(Object[] channels)
          Hide the following channels.
 RedwoodConfiguration loggingClass(Class<?> classToIgnoreInTraces)
          Set a Java class to ignore when printing stack traces
 RedwoodConfiguration loggingClass(String classToIgnoreInTraces)
          Set a Java classname path to ignore when printing stack traces
 RedwoodConfiguration neatExit()
          Close tracks when the JVM shuts down.
static RedwoodConfiguration parse(Properties props)
          Configure Redwood (from scratch) based on a Properties file.
 RedwoodConfiguration printChannels(int width)
          Print channels to the left of log messages
 RedwoodConfiguration rootHandler(LogRecordHandler handler)
          Add a custom Log Record Handler to the root of the tree
 RedwoodConfiguration showOnlyChannels(Object[] channels)
          Show only the following channels.
 RedwoodConfiguration splice(LogRecordHandler parent, LogRecordHandler toAdd, LogRecordHandler grandchild)
          Add a handler to as a child of an existing parent
static RedwoodConfiguration standard()
          The default Redwood configuration, which prints to the console.
 RedwoodConfiguration stderr()
          Add a console pipeline to the Redwood handler tree, printing to stderr.
 RedwoodConfiguration stdout()
          Add a console pipeline to the Redwood handler tree, printing to stdout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RedwoodConfiguration

protected RedwoodConfiguration()
Private constructor to prevent use of "new RedwoodConfiguration()"

Method Detail

apply

public void apply()
Apply this configuration to Redwood


clear

public RedwoodConfiguration clear()
Clear any custom configurations to Redwood

Returns:
this

stdout

public RedwoodConfiguration stdout()
Add a console pipeline to the Redwood handler tree, printing to stdout. Calling this multiple times will result in messages being printed multiple times.

Returns:
this

stderr

public RedwoodConfiguration stderr()
Add a console pipeline to the Redwood handler tree, printing to stderr. Calling this multiple times will result in messages being printed multiple times.

Returns:
this

console

public RedwoodConfiguration console()
Add a console pipeline to the Redwood handler tree, Calling this multiple times will result in messages being printed multiple times.

Returns:
this

file

public RedwoodConfiguration file(String file)
Add a file pipeline to the Redwood handler tree. That is, print log messages to a given file. Calling this multiple times will result in messages being printed to multiple files (or, multiple times to the same file).

Parameters:
file - The path of the file to log to. This path is not checked for correctness here.
Returns:
this

rootHandler

public RedwoodConfiguration rootHandler(LogRecordHandler handler)
Add a custom Log Record Handler to the root of the tree

Parameters:
handler - The handler to add
Returns:
this

handler

public RedwoodConfiguration handler(LogRecordHandler parent,
                                    LogRecordHandler child)
Add a handler to as a child of an existing parent

Parameters:
parent - The handler to extend
child - The new handler to add
Returns:
this

splice

public RedwoodConfiguration splice(LogRecordHandler parent,
                                   LogRecordHandler toAdd,
                                   LogRecordHandler grandchild)
Add a handler to as a child of an existing parent

Parameters:
parent - The handler to extend
toAdd - The new handler to add
grandchild - The subtree to attach to the new handler
Returns:
this

loggingClass

public RedwoodConfiguration loggingClass(String classToIgnoreInTraces)
Set a Java classname path to ignore when printing stack traces

Parameters:
classToIgnoreInTraces - The class name (with packages, etc) to ignore.
Returns:
this

loggingClass

public RedwoodConfiguration loggingClass(Class<?> classToIgnoreInTraces)
Set a Java class to ignore when printing stack traces

Parameters:
classToIgnoreInTraces - The class to ignore.
Returns:
this

collapseApproximate

public RedwoodConfiguration collapseApproximate()
Collapse repeated records, using an approximate notion of equality (i.e. records begin or end with the same substring) This is useful for cases such as tracking iterations ("iter 1" and "iter 2" are considered the same record).

Returns:
this

collapseExact

public RedwoodConfiguration collapseExact()
Collapse repeated records, using exact string match on the record. This is generally useful for making very verbose logs more readable.

Returns:
this

collapseNone

public RedwoodConfiguration collapseNone()
Do not collapse repeated records

Returns:
this

captureStdout

public RedwoodConfiguration captureStdout()
Capture stdout and route them through Redwood

Returns:
this

captureStderr

public RedwoodConfiguration captureStderr()
Capture stderr and route them through Redwood

Returns:
this

captureStreams

public RedwoodConfiguration captureStreams()
Capture stdout and stderr and route them through Redwood

Returns:
this

neatExit

public RedwoodConfiguration neatExit()
Close tracks when the JVM shuts down.

Returns:
this

printChannels

public RedwoodConfiguration printChannels(int width)
Print channels to the left of log messages

Parameters:
width - The width (in characters) to print the channels
Returns:
this

hideChannels

public RedwoodConfiguration hideChannels(Object[] channels)
Hide the following channels.

Parameters:
channels - The names of the channels to hide.
Returns:
this

showOnlyChannels

public RedwoodConfiguration showOnlyChannels(Object[] channels)
Show only the following channels.

Parameters:
channels - The names of the channels to show.
Returns:
this

empty

public static RedwoodConfiguration empty()
An empty Redwood configuration. Note that without a Console Handler, Redwood will not print anything

Returns:
An empty Redwood Configuration object.

standard

public static RedwoodConfiguration standard()
The default Redwood configuration, which prints to the console. This is the usual starting point for new configurations.

Returns:
A basic Redwood Configuration.

current

public static RedwoodConfiguration current()
The current Redwood configuration; this is used to make incremental changes to an existing custom configuration.

Returns:
The current Redwood configuration.

parse

public static RedwoodConfiguration parse(Properties props)
Configure Redwood (from scratch) based on a Properties file. Currently recognized properties are:

Parameters:
props - The properties to use in configuration
Returns:
A new Redwood Configuration based on the passed properties, ignoring any existing custom configuration

apply

public static void apply(Properties props)
Parses a properties file and applies it immediately to Redwood

Parameters:
props - The properties to apply


Stanford NLP Group