intarsys runtime library

de.intarsys.tools.logging
Class ThreadFilter

java.lang.Object
  extended by de.intarsys.tools.logging.ThreadFilter
All Implemented Interfaces:
Filter

public class ThreadFilter
extends Object
implements Filter

Only accept log requests within a dedicated thread.

This is for example suitable in a scenario where a log should be associated with a functor object but the functor is executed in different worker threads. If the functor activates its filter upon entry, all activities can be sent to the same log, even from different workers. In this case the thread associated with the filter is switched with "activate" and "deactivate". These methods should always be used in a "finally" style block.

Another scenario is where a thread has a dedicated task and all its activities have to be logged. Here the thread is associated at startup and remains the same.


Constructor Summary
ThreadFilter(boolean activate)
           
 
Method Summary
 boolean activate()
           
 boolean deactivate()
           
 boolean isActive()
           
 boolean isLoggable(LogRecord record)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadFilter

public ThreadFilter(boolean activate)
Method Detail

activate

public boolean activate()

deactivate

public boolean deactivate()

isActive

public boolean isActive()

isLoggable

public boolean isLoggable(LogRecord record)
Specified by:
isLoggable in interface Filter

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.