com.netflix.blitz4j
Class LoggingContext

java.lang.Object
  extended by com.netflix.blitz4j.LoggingContext

public class LoggingContext
extends java.lang.Object

The utility class that caches the context of logging such as location information.

It is expensive to find out the location information (ie) calling class, line number etc of the logger and hence caching would be useful whenever possible. This class also generates location information slightly more efficiently than log4j.


Method Summary
 org.apache.log4j.spi.LocationInfo generateLocationInfo(org.apache.log4j.spi.LoggingEvent event)
          Generate the location information of the given logging event and cache it.
static LoggingContext getInstance()
           
 org.apache.log4j.spi.LocationInfo getLocationInfo(java.lang.Class wrapperClassName)
          Get the location information of the calling class
 org.apache.log4j.spi.LocationInfo getLocationInfo(org.apache.log4j.spi.LoggingEvent event)
          Get the location information of the logging event.
 java.lang.StackTraceElement getStackTraceElement(java.lang.Class stackClass)
          Gets the starting calling stack trace element of a given stack which matches the given class name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getStackTraceElement

public java.lang.StackTraceElement getStackTraceElement(java.lang.Class stackClass)
Gets the starting calling stack trace element of a given stack which matches the given class name. Given the wrapper class name, the match continues until the last stack trace element of the wrapper class is matched.

Parameters:
stackClass - - The class to be matched for. Get the last matching class down the stack
Returns:
- StackTraceElement which denotes the calling point of given class or wrapper class

getLocationInfo

public org.apache.log4j.spi.LocationInfo getLocationInfo(java.lang.Class wrapperClassName)
Get the location information of the calling class

Parameters:
wrapperClassName - - The wrapper that indicates the caller
Returns:
the location information

getInstance

public static LoggingContext getInstance()

generateLocationInfo

public org.apache.log4j.spi.LocationInfo generateLocationInfo(org.apache.log4j.spi.LoggingEvent event)
Generate the location information of the given logging event and cache it.

Parameters:
event - The logging event for which the location information needs to be determined.
Returns:
The location info object contains information about the logger.

getLocationInfo

public org.apache.log4j.spi.LocationInfo getLocationInfo(org.apache.log4j.spi.LoggingEvent event)
Get the location information of the logging event. If the information has been cached it is retrieved from the MDC (for asynchronous events MDCs are retained), else it is generated.

Parameters:
event - - The logging event