public class Redwood
extends java.lang.Object
LogRecordHandler.
New handlers should implement this class.
Details on configuring Redwood can be found in the RedwoodConfiguration class.
New configuration methods should be implemented in this class, following the standard
builder paradigm.
There is a tutorial on Redwood on the
NLP website.| Modifier and Type | Class and Description |
|---|---|
static class |
Redwood.ConsoleHandler
Default output handler which actually prints things to the real System.out
|
static class |
Redwood.FileHandler
Handler which prints to a specified file
TODO: make constructors for other ways of describing files (File, for example!)
|
protected static class |
Redwood.Flag
Standard channels; enum for the sake of efficiency
|
static class |
Redwood.Record
A log record, which encapsulates the information needed
to eventually display the enclosed message.
|
protected static class |
Redwood.RecordHandlerTree
A tree structure of record handlers
|
static class |
Redwood.RedwoodChannels
Represents a collection of channels.
|
static class |
Redwood.Util
A utility class for Redwood intended for static import
(import static edu.stanford.nlp.util.logging.Redwood.Util.*;),
providing a wrapper for Redwood functions and adding utility shortcuts
|
| Modifier and Type | Field and Description |
|---|---|
static Redwood.Flag |
DBG |
static Redwood.Flag |
ERR |
static Redwood.Flag |
FORCE |
static Redwood.Flag |
STDERR |
static Redwood.Flag |
STDOUT |
static Redwood.Flag |
WARN |
| Constructor and Description |
|---|
Redwood() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addLoggingClass(java.lang.String className)
Add a class to the list of known logging classes.
|
protected static void |
appendHandler(java.lang.Class<? extends LogRecordHandler> parent,
LogRecordHandler child)
Append a Handler to every parent of the given class
|
protected static void |
appendHandler(LogRecordHandler child)
Append a Handler to the end of the root of the Handler tree.
|
protected static void |
appendHandler(LogRecordHandler parent,
LogRecordHandler child)
Append a Handler to a portion of the handler tree
|
protected static void |
captureSystemStreams(boolean captureOut,
boolean captureErr)
Captures System.out and System.err and redirects them
to Redwood logging.
|
static Redwood.RedwoodChannels |
channels(java.lang.Object... channelNames)
Create an object representing a group of channels.
|
protected static void |
clearHandlers()
Remove all log handlers from Redwood, presumably in order to
construct a custom pipeline afterwards
|
protected static void |
clearLoggingClasses()
Removes all classes from the list of known logging classes
|
static void |
endThreads(java.lang.String check)
Signal that all threads have run to completion, and the multithreaded
environment is over.
|
static void |
endTrack()
A utility method for closing calls to the anonymous startTrack() call.
|
static void |
endTrack(java.lang.String title)
End a "track;" that is, return to logging at one level shallower.
|
protected static java.util.List<java.lang.StackTraceElement> |
filterStackTrace(java.lang.StackTraceElement[] stack)
Removes logging classes from a stack trace.
|
static void |
finishThread()
Signal that this thread will not log any more messages in the multithreaded
environment
|
static void |
forceTrack()
Helper method to start an anonymous track on the FORCE channel.
|
static void |
forceTrack(java.lang.Object arg)
Helper method to start a track on the FORCE channel.
|
protected static void |
formatTimeDifference(long diff,
java.lang.StringBuilder b)
Utility method for formatting a time difference (maybe this should go to a util class?)
|
static void |
hideAllChannels()
Hide all channels.
|
static void |
hideChannels(java.lang.Object... channels)
Hide multiple channels.
|
static void |
hideOnlyChannels(java.lang.Object... channels)
Hide multiple channels.
|
static void |
log(java.lang.Object... args)
Log a message.
|
static void |
logf(java.lang.String format,
java.lang.Object... args)
The Redwood equivalent to printf().
|
static void |
main(java.lang.String[] args)
Various informal tests of Redwood functionality
|
protected static <E extends LogRecordHandler> |
removeHandler(java.lang.Class<E> toRemove)
Remove a handler from the list
|
protected static void |
restoreSystemStreams()
Restores System.out and System.err to their original values
|
static void |
showAllChannels()
Show all channels.
|
static void |
showChannels(java.lang.Object... channels)
Show multiple channels.
|
static void |
showOnlyChannels(java.lang.Object... channels)
Show only the given channel.
|
protected static void |
spliceHandler(java.lang.Class<? extends LogRecordHandler> parent,
LogRecordHandler toAdd,
java.lang.Class<? extends LogRecordHandler> grandchild) |
protected static void |
spliceHandler(LogRecordHandler parent,
LogRecordHandler toAdd,
java.lang.Class<? extends LogRecordHandler> grandchild) |
protected static void |
spliceHandler(LogRecordHandler parent,
LogRecordHandler toAdd,
LogRecordHandler grandchild) |
static void |
startThreads(java.lang.String title)
Start a multithreaded logging environment.
|
static void |
startTrack(java.lang.Object... args)
Begin a "track;" that is, begin logging at one level deeper.
|
static void |
stop()
Stop Redwood, closing all tracks and prohibiting future log messages.
|
protected static boolean |
supportsAnsi() |
public static final Redwood.Flag ERR
public static final Redwood.Flag WARN
public static final Redwood.Flag DBG
public static final Redwood.Flag FORCE
public static final Redwood.Flag STDOUT
public static final Redwood.Flag STDERR
protected static <E extends LogRecordHandler> boolean removeHandler(java.lang.Class<E> toRemove)
toRemove - The handler to remove. Any handler object that
matches this class will be removed.protected static void spliceHandler(LogRecordHandler parent, LogRecordHandler toAdd, LogRecordHandler grandchild)
protected static void spliceHandler(LogRecordHandler parent, LogRecordHandler toAdd, java.lang.Class<? extends LogRecordHandler> grandchild)
protected static void spliceHandler(java.lang.Class<? extends LogRecordHandler> parent, LogRecordHandler toAdd, java.lang.Class<? extends LogRecordHandler> grandchild)
protected static void appendHandler(LogRecordHandler parent, LogRecordHandler child)
parent - The parent to add the child tochild - The Handler to add.protected static void appendHandler(java.lang.Class<? extends LogRecordHandler> parent, LogRecordHandler child)
parent - The class of the parents to add the child tochild - The Handler to add.protected static void appendHandler(LogRecordHandler child)
child - The Handler to add.protected static void clearHandlers()
protected static void captureSystemStreams(boolean captureOut,
boolean captureErr)
captureOut - True is System.out should be capturedcaptureErr - True if System.err should be capturedprotected static void restoreSystemStreams()
protected static void addLoggingClass(java.lang.String className)
className - The class to report as a logging classprotected static void clearLoggingClasses()
public static void log(java.lang.Object... args)
args - The last argument is the message; the first arguments are the channels.public static void logf(java.lang.String format,
java.lang.Object... args)
format - The format string, as per java's Formatter.format() object.args - The arguments to format.public static void startTrack(java.lang.Object... args)
args - The title of the track to begin, with an optional FORCE flag.public static void forceTrack(java.lang.Object arg)
arg - public static void forceTrack()
public static void endTrack(java.lang.String title)
title - A title that should match the beginning of this track.public static void endTrack()
public static void startThreads(java.lang.String title)
title - The name of the thread group being startedpublic static void finishThread()
public static void endThreads(java.lang.String check)
check - The name of the thread group passed to startThreads()public static Redwood.RedwoodChannels channels(java.lang.Object... channelNames)
Redwood.RedwoodChannels contains a more complete description.Redwood.RedwoodChannelspublic static void showOnlyChannels(java.lang.Object... channels)
channels - The channels to showpublic static void hideOnlyChannels(java.lang.Object... channels)
channels - The channels to hidepublic static void showChannels(java.lang.Object... channels)
channels - The channels to showpublic static void hideChannels(java.lang.Object... channels)
channels - The channels to hidepublic static void showAllChannels()
public static void hideAllChannels()
public static void stop()
protected static void formatTimeDifference(long diff,
java.lang.StringBuilder b)
diff - Time difference in millisecondsb - The string builder to append toprotected static java.util.List<java.lang.StackTraceElement> filterStackTrace(java.lang.StackTraceElement[] stack)
protected static boolean supportsAnsi()
public static void main(java.lang.String[] args)
args - Unused