- java.lang.Object
 - 
- com.github.robtimus.pool.PoolLogger
 
 
- 
public class PoolLogger extends Object
A logger for events triggered by aPoolorPoolableObject.Instances of this class are thread-safe.
This class needs SLF4J to be present on the class path to work. If it isn't nothing will be logged at all.
- Author:
 - Rob Spoor
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPoolLogger.BuilderA builder forPoolLoggerobjects. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquiredObject(PoolableObject<?> object, int idleCount, int poolSize)Called when aPoolableObjectis acquired from aPool.voidcreatedNonPooledObject(PoolableObject<?> object)Called when a newPoolableObjecthas been created that will not be returned to the pool it was acquired from.voidcreatedObject(PoolableObject<?> object)Called when a newPoolableObjecthas been created.voidcreatedPool(PoolConfig config)Called when aPoolhas been created.voidcreatingPool(PoolConfig config)Called when aPoolis being created.static PoolLogger.Buildercustom()Returns a new builder for creatingPoolLoggerobjects.voiddecreasedObjectRefCount(PoolableObject<?> object, int refCount)Called when a reference was removed from aPoolableObject.static PoolLoggerdefaultLogger()Returns a defaultPoolLoggerobject.voiddrainedPool(int poolSize)Called when aPoolis drained.voidfailedToCreatePool(Exception exception)Called when aPoolcould not be created.voidincreasedObjectRefCount(PoolableObject<?> object, int refCount)Called when an additional reference was added to aPoolableObject.booleanisEnabled(LogLevel level)Returns whether or not logging at a specific level is enabled.static PoolLoggernoopLogger()Returns aPoolLoggerobject that does not perform any actual logging.voidobjectEvent(LogLevel level, PoolableObject<?> object, String message)Called whenPoolableObject.logEvent(LogLevel, String)is called.voidobjectEvent(LogLevel level, PoolableObject<?> object, Supplier<String> messageSupplier)Called whenPoolableObject.logEvent(LogLevel, Supplier)is called.voidobjectIdleTooLong(PoolableObject<?> object, int idleCount, int poolSize)Called when aPoolableObjecthas been idle for too long.voidobjectInvalidated(PoolableObject<?> object, int idleCount, int poolSize)Called when aPoolableObjectis no longer valid and has been removed from itsPool.voidreleasedObjectResources(PoolableObject<?> object)Called when the resources of aPoolableObjecthave been released.voidreleaseObjectResourcesFailed(PoolableObject<?> object, Exception exception)Called when an error occurs when quietly releasing the resources of aPoolableObject.voidreleasingObjectResources(PoolableObject<?> object)Called before the resources of aPoolableObjectwill be released.voidreturnedObject(PoolableObject<?> object, int idleCount, int poolSize)Called when aPoolableObjectis returned to aPool.voidshutDownPool()Called when aPoolhas shut down.StringtoString() 
 - 
 
- 
- 
Method Detail
- 
creatingPool
public void creatingPool(PoolConfig config)
Called when aPoolis being created.- Parameters:
 config- The configuration for thePool.
 
- 
createdPool
public void createdPool(PoolConfig config)
Called when aPoolhas been created.- Parameters:
 config- The configuration for thePool.
 
- 
failedToCreatePool
public void failedToCreatePool(Exception exception)
Called when aPoolcould not be created.- Parameters:
 exception- The exception that was thrown while creating thePool.
 
- 
drainedPool
public void drainedPool(int poolSize)
Called when aPoolis drained. This is like acquiring all available idlePoolableObjects in one call.- Parameters:
 poolSize- The total pool size - the number of acquiredPoolableObjects.
 
- 
shutDownPool
public void shutDownPool()
Called when aPoolhas shut down. 
- 
createdObject
public void createdObject(PoolableObject<?> object)
Called when a newPoolableObjecthas been created.- Parameters:
 object- ThePoolableObject.
 
- 
createdNonPooledObject
public void createdNonPooledObject(PoolableObject<?> object)
Called when a newPoolableObjecthas been created that will not be returned to the pool it was acquired from.- Parameters:
 object- ThePoolableObject.
 
- 
increasedObjectRefCount
public void increasedObjectRefCount(PoolableObject<?> object, int refCount)
Called when an additional reference was added to aPoolableObject.- Parameters:
 object- ThePoolableObject.refCount- The new number of references, including thePoolableObjectitself.- See Also:
 PoolableObject.addReference()
 
- 
decreasedObjectRefCount
public void decreasedObjectRefCount(PoolableObject<?> object, int refCount)
Called when a reference was removed from aPoolableObject.- Parameters:
 object- ThePoolableObject.refCount- The new number of references, including thePoolableObjectitself.- See Also:
 PoolableObject.Reference.remove()
 
- 
releasingObjectResources
public void releasingObjectResources(PoolableObject<?> object)
Called before the resources of aPoolableObjectwill be released.- Parameters:
 object- ThePoolableObject.- See Also:
 PoolableObject.releaseResources()
 
- 
releasedObjectResources
public void releasedObjectResources(PoolableObject<?> object)
Called when the resources of aPoolableObjecthave been released.- Parameters:
 object- ThePoolableObject.- See Also:
 PoolableObject.releaseResources()
 
- 
releaseObjectResourcesFailed
public void releaseObjectResourcesFailed(PoolableObject<?> object, Exception exception)
Called when an error occurs when quietly releasing the resources of aPoolableObject.- Parameters:
 object- ThePoolableObject.exception- The exception that was thrown while quietly releasing the resources of thePoolableObject.- See Also:
 PoolableObject.releaseResources()
 
- 
acquiredObject
public void acquiredObject(PoolableObject<?> object, int idleCount, int poolSize)
Called when aPoolableObjectis acquired from aPool.- Parameters:
 object- ThePoolableObject.idleCount- The number of idlePoolableObjects after acquiring thePoolableObject.poolSize- The total pool size - the number of acquired and idlePoolableObjects combined.
 
- 
returnedObject
public void returnedObject(PoolableObject<?> object, int idleCount, int poolSize)
Called when aPoolableObjectis returned to aPool.- Parameters:
 object- ThePoolableObject.idleCount- The number of idlePoolableObjects after returning thePoolableObject.poolSize- The total pool size - the number of acquired and idlePoolableObjects combined.
 
- 
objectInvalidated
public void objectInvalidated(PoolableObject<?> object, int idleCount, int poolSize)
Called when aPoolableObjectis no longer valid and has been removed from itsPool.- Parameters:
 object- ThePoolableObject.idleCount- The number of idlePoolableObjects after invalidating thePoolableObject.poolSize- The total pool size - the number of acquired and idlePoolableObjects combined.- See Also:
 PoolableObject.validate()
 
- 
objectIdleTooLong
public void objectIdleTooLong(PoolableObject<?> object, int idleCount, int poolSize)
Called when aPoolableObjecthas been idle for too long.- Parameters:
 object- ThePoolableObject.idleCount- The number of idlePoolableObjects after invalidating thePoolableObject.poolSize- The total pool size - the number of acquired and idlePoolableObjects combined.
 
- 
objectEvent
public void objectEvent(LogLevel level, PoolableObject<?> object, String message)
Called whenPoolableObject.logEvent(LogLevel, String)is called.- Parameters:
 level- The log level to use.object- ThePoolableObject.message- The event message.
 
- 
objectEvent
public void objectEvent(LogLevel level, PoolableObject<?> object, Supplier<String> messageSupplier)
Called whenPoolableObject.logEvent(LogLevel, Supplier)is called.- Parameters:
 level- The log level to use.object- ThePoolableObject.messageSupplier- A supplier for the event message.
 
- 
isEnabled
public boolean isEnabled(LogLevel level)
Returns whether or not logging at a specific level is enabled. This can be used to perform conditional configuration, like adding logging listeners conditionally.- Parameters:
 level- The level to check.- Returns:
 trueif logging at the given level is enabled, orfalseotherwise.
 
- 
defaultLogger
public static PoolLogger defaultLogger()
Returns a defaultPoolLoggerobject. This has the same configuration as an object returned bycustom().build().- Returns:
 - A default 
PoolLoggerobject. 
 
- 
noopLogger
public static PoolLogger noopLogger()
Returns aPoolLoggerobject that does not perform any actual logging. This can be used as default value in case no logger should be used, instead of checking fornull.- Returns:
 - A 
PoolLoggerobject that does not perform any actual logging. 
 
- 
custom
public static PoolLogger.Builder custom()
Returns a new builder for creatingPoolLoggerobjects.- Returns:
 - A new builder for creating 
PoolLoggerobjects. 
 
 - 
 
 -