org.shiftone.jrat.util.log.target
Class ThreadLocalLogTarget

java.lang.Object
  extended by org.shiftone.jrat.util.log.target.ThreadLocalLogTarget
All Implemented Interfaces:
LogTarget

public class ThreadLocalLogTarget
extends java.lang.Object
implements LogTarget

This is a LogTarget that uses a delegate LogTarget that lives on the thread. This makes it possible to run a command within a scope, and have the activities of that scope to be logged to a different LogTarget - but only during the duration of that command.

Author:
jeff@shiftone.org (Jeff Drost)

Field Summary
 java.lang.ThreadLocal threadLocal
           
 
Constructor Summary
ThreadLocalLogTarget()
           
ThreadLocalLogTarget(LogTarget target)
           
 
Method Summary
 void executeInScope(LogTarget newTarget, java.lang.Runnable runnable)
           
 boolean isLevelEnabled(java.lang.String topic, int level)
           
 void log(java.lang.String topic, int level, java.lang.Object message, java.lang.Throwable throwable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threadLocal

public java.lang.ThreadLocal threadLocal
Constructor Detail

ThreadLocalLogTarget

public ThreadLocalLogTarget()

ThreadLocalLogTarget

public ThreadLocalLogTarget(LogTarget target)
Method Detail

isLevelEnabled

public boolean isLevelEnabled(java.lang.String topic,
                              int level)
Specified by:
isLevelEnabled in interface LogTarget

log

public void log(java.lang.String topic,
                int level,
                java.lang.Object message,
                java.lang.Throwable throwable)
Specified by:
log in interface LogTarget

executeInScope

public void executeInScope(LogTarget newTarget,
                           java.lang.Runnable runnable)