edu.stanford.nlp.util.logging
Class RedirectOutputHandler<LoggerClass,ChannelEquivalent>

java.lang.Object
  extended by edu.stanford.nlp.util.logging.LogRecordHandler
      extended by edu.stanford.nlp.util.logging.OutputHandler
          extended by 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

Field Summary
 LoggerClass logger
           
 java.lang.reflect.Method loggingMethod
           
 
Fields inherited from class edu.stanford.nlp.util.logging.OutputHandler
addRandomColors, channelColors, channelSeparatorChar, channelStyles, info, leftMargin, minLineCountForTrackNameReminder, queuedTracks, tab, trackColor, trackStack, trackStyle
 
Fields inherited from class edu.stanford.nlp.util.logging.LogRecordHandler
EMPTY
 
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 edu.stanford.nlp.util.logging.OutputHandler
colorChannel, handle, setColorChannels, signalEndTrack, signalStartTrack, style, styleChannel
 
Methods inherited from class edu.stanford.nlp.util.logging.LogRecordHandler
signalShutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public final LoggerClass logger

loggingMethod

public final java.lang.reflect.Method loggingMethod
Constructor Detail

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.Logger
loggingMethod - 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.Logger
loggingMethod - 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.
Method Detail

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 to
channelStr - The [possibly truncated and/or modified] string to actually print to the StringBuilder
channel - 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