edu.stanford.nlp.util.logging
Class RedirectOutputHandler<LoggerClass,ChannelEquivalent>
java.lang.Object
edu.stanford.nlp.util.logging.LogRecordHandler
edu.stanford.nlp.util.logging.OutputHandler
edu.stanford.nlp.util.logging.RedirectOutputHandler<LoggerClass,ChannelEquivalent>
public class RedirectOutputHandler<LoggerClass,ChannelEquivalent>
- extends OutputHandler
A class to redirect the output of Redwood to another logging mechanism,
e.g., java.util.logging.
- Author:
- Gabor Angeli
Fields inherited from class edu.stanford.nlp.util.logging.OutputHandler |
addRandomColors, channelColors, channelSeparatorChar, channelStyles, info, leftMargin, minLineCountForTrackNameReminder, queuedTracks, tab, trackColor, trackStack, trackStyle |
Constructor Summary |
RedirectOutputHandler(LoggerClass logger,
java.lang.reflect.Method loggingMethod)
Create a redirect handler, with a logging class, ignoring logging
levels. |
RedirectOutputHandler(LoggerClass logger,
java.lang.reflect.Method loggingMethod,
java.util.Map<java.lang.Object,ChannelEquivalent> channelMapping,
ChannelEquivalent defaultChannel)
Create a redirect handler, with a logging class, redirecting both the logging
message, and the channel that it came from |
Method Summary |
protected boolean |
formatChannel(java.lang.StringBuilder b,
java.lang.String channelStr,
java.lang.Object channel)
Ensure that we don't print duplicate channels when adapting to another logging framework. |
static RedirectOutputHandler<java.util.logging.Logger,java.util.logging.Level> |
fromJavaUtilLogging(java.util.logging.Logger logger)
|
void |
print(java.lang.Object[] channels,
java.lang.String line)
Print a string to an output without the trailing newline. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
public final LoggerClass logger
loggingMethod
public final java.lang.reflect.Method loggingMethod
RedirectOutputHandler
public RedirectOutputHandler(LoggerClass logger,
java.lang.reflect.Method loggingMethod)
- Create a redirect handler, with a logging class, ignoring logging
levels.
- Parameters:
logger
- The class to use for logging. For example, java.util.logging.LoggerloggingMethod
- A method which takes a *single* String argument
and logs that string using the |logger| class.
RedirectOutputHandler
public RedirectOutputHandler(LoggerClass logger,
java.lang.reflect.Method loggingMethod,
java.util.Map<java.lang.Object,ChannelEquivalent> channelMapping,
ChannelEquivalent defaultChannel)
- Create a redirect handler, with a logging class, redirecting both the logging
message, and the channel that it came from
- Parameters:
logger
- The class to use for logging. For example,
java.util.logging.LoggerloggingMethod
- A method which takes a *single* String argument
and logs that string using the |logger| class.channelMapping
- The mapping from Redwood channels, to the native Channel equivalent.
print
public void print(java.lang.Object[] channels,
java.lang.String line)
- Description copied from class:
OutputHandler
- Print a string to an output without the trailing newline.
Many output handlers can get by with just implementing this method.
- Specified by:
print
in class OutputHandler
- Parameters:
channels
- The channels this message was printed on; in most cases
an implementing handler should not have to do anything with
this. The channels should not be printed here.
The channels may be null.line
- The string to be printed.
formatChannel
protected boolean formatChannel(java.lang.StringBuilder b,
java.lang.String channelStr,
java.lang.Object channel)
- Ensure that we don't print duplicate channels when adapting to another logging framework.
- Overrides:
formatChannel
in class OutputHandler
- Parameters:
b
- The StringBuilder to append tochannelStr
- The [possibly truncated and/or modified] string
to actually print to the StringBuilderchannel
- The original channel
- Returns:
- |true| if the channel was printed (that is, appended to the StringBuilder)
fromJavaUtilLogging
public static RedirectOutputHandler<java.util.logging.Logger,java.util.logging.Level> fromJavaUtilLogging(java.util.logging.Logger logger)
Stanford NLP Group