public class Redwood extends 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 |
protected static PrintStream |
realSysErr
The real System.err stream
|
protected static PrintStream |
realSysOut
The real System.out stream
|
static Redwood.Flag |
STDERR |
static Redwood.Flag |
STDOUT |
static boolean |
supportsAnsi |
static Redwood.Flag |
WARN |
Modifier and Type | Method and Description |
---|---|
protected static void |
captureSystemStreams(boolean captureOut,
boolean captureErr)
Captures System.out and System.err and redirects them
to Redwood logging.
|
static Redwood.RedwoodChannels |
channels(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
|
static void |
endThreads(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(String title)
End a "track;" that is, return to logging at one level shallower.
|
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(Object name)
Helper method to start a track on the FORCE channel.
|
static String |
formatTimeDifference(long diff) |
protected static void |
formatTimeDifference(long diff,
StringBuilder b)
Utility method for formatting a time difference (maybe this should go to a util class?)
|
static void |
hideChannelsEverywhere(Object... channels)
Hide multiple channels.
|
static void |
log(Object... args)
Log a message.
|
static void |
logf(String format,
Object... args)
The Redwood equivalent to printf().
|
static void |
main(String[] args)
Various informal tests of Redwood functionality
|
protected static void |
restoreSystemStreams()
Restores System.out and System.err to their original values
|
protected static Redwood.RecordHandlerTree |
rootHandler() |
static void |
startThreads(String title)
Start a multithreaded logging environment.
|
static void |
startTrack(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.
|
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 final PrintStream realSysOut
protected static final PrintStream realSysErr
public static final boolean supportsAnsi
protected static Redwood.RecordHandlerTree rootHandler()
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()
public static void log(Object... args)
args
- The last argument is the message; the first arguments are the channels.public static void logf(String format, Object... args)
format
- The format string, as per java's Formatter.format() object.args
- The arguments to format.public static void startTrack(Object... args)
args
- The title of the track to begin, with an optional FORCE flag.public static void forceTrack(Object name)
name
- The track name to printpublic static void forceTrack()
public static void endTrack(String title)
title
- A title that should match the beginning of this track.public static void endTrack()
public static void startThreads(String title)
title
- The name of the thread group being startedpublic static void finishThread()
public static void endThreads(String check)
check
- The name of the thread group passed to startThreads()public static Redwood.RedwoodChannels channels(Object... channelNames)
Redwood.RedwoodChannels
contains a more complete description.Redwood.RedwoodChannels
public static void hideChannelsEverywhere(Object... channels)
channels
- The channels to hidepublic static void stop()
protected static void formatTimeDifference(long diff, StringBuilder b)
diff
- Time difference in millisecondsb
- The string builder to append topublic static String formatTimeDifference(long diff)
public static void main(String[] args)
args
- Unused