org.log4mongo
Class LoggingEventBsonifierImpl

java.lang.Object
  extended by org.log4mongo.LoggingEventBsonifierImpl
All Implemented Interfaces:
LoggingEventBsonifier

public class LoggingEventBsonifierImpl
extends java.lang.Object
implements LoggingEventBsonifier

Default implementation class for creating a BSON representation of a Log4J LoggingEvent.


Constructor Summary
LoggingEventBsonifierImpl()
           
 
Method Summary
protected  void addHostnameInformation(com.mongodb.DBObject bson)
          Adds the current process's host name, VM name and IP address
protected  void addLocationInformation(com.mongodb.DBObject bson, org.apache.log4j.spi.LocationInfo locationInfo)
          Adds the LocationInfo object to an existing BSON object.
protected  void addMDCInformation(com.mongodb.DBObject bson, java.util.Map<java.lang.Object,java.lang.Object> props)
          Adds MDC Properties to the DBObject.
protected  void addThrowableInformation(com.mongodb.DBObject bson, org.apache.log4j.spi.ThrowableInformation throwableInfo)
          Adds the ThrowableInformation object to an existing BSON object.
 com.mongodb.DBObject bsonify(org.apache.log4j.spi.LoggingEvent loggingEvent)
          BSONifies a single Log4J LoggingEvent object.
protected  com.mongodb.DBObject bsonifyClassName(java.lang.String className)
          BSONifies the given class name.
protected  com.mongodb.DBObject bsonifyStackTrace(java.lang.StackTraceElement[] stackTrace)
          BSONifies the given stack trace.
protected  com.mongodb.DBObject bsonifyStackTraceElement(java.lang.StackTraceElement element)
          BSONifies the given stack trace element.
protected  com.mongodb.DBObject bsonifyThrowable(java.lang.Throwable throwable)
          BSONifies the given Throwable.
protected  void nullSafePut(com.mongodb.DBObject bson, java.lang.String key, java.lang.Object value)
          Adds the given value to the given key, except if it's null (in which case this method does nothing).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingEventBsonifierImpl

public LoggingEventBsonifierImpl()
Method Detail

bsonify

public com.mongodb.DBObject bsonify(org.apache.log4j.spi.LoggingEvent loggingEvent)
BSONifies a single Log4J LoggingEvent object.

Specified by:
bsonify in interface LoggingEventBsonifier
Parameters:
loggingEvent - The LoggingEvent object to BSONify (may be null).
Returns:
The BSONified equivalent of the LoggingEvent object (may be null).

addMDCInformation

protected void addMDCInformation(com.mongodb.DBObject bson,
                                 java.util.Map<java.lang.Object,java.lang.Object> props)
Adds MDC Properties to the DBObject.

Parameters:
bson - The root DBObject
props - MDC Properties to be logged

addLocationInformation

protected void addLocationInformation(com.mongodb.DBObject bson,
                                      org.apache.log4j.spi.LocationInfo locationInfo)
Adds the LocationInfo object to an existing BSON object.

Parameters:
bson - The BSON object to add the location info to (must not be null).
locationInfo - The LocationInfo object to add to the BSON object (may be null).

addThrowableInformation

protected void addThrowableInformation(com.mongodb.DBObject bson,
                                       org.apache.log4j.spi.ThrowableInformation throwableInfo)
Adds the ThrowableInformation object to an existing BSON object.

Parameters:
bson - The BSON object to add the throwable info to (must not be null).
throwableInfo - The ThrowableInformation object to add to the BSON object (may be null).

addHostnameInformation

protected void addHostnameInformation(com.mongodb.DBObject bson)
Adds the current process's host name, VM name and IP address

Parameters:
bson - A BSON object containing host name, VM name and IP address

bsonifyThrowable

protected com.mongodb.DBObject bsonifyThrowable(java.lang.Throwable throwable)
BSONifies the given Throwable.

Parameters:
throwable - The throwable object to BSONify (may be null).
Returns:
The BSONified equivalent of the Throwable object (may be null).

bsonifyStackTrace

protected com.mongodb.DBObject bsonifyStackTrace(java.lang.StackTraceElement[] stackTrace)
BSONifies the given stack trace.

Parameters:
stackTrace - The stack trace object to BSONify (may be null).
Returns:
The BSONified equivalent of the stack trace object (may be null).

bsonifyStackTraceElement

protected com.mongodb.DBObject bsonifyStackTraceElement(java.lang.StackTraceElement element)
BSONifies the given stack trace element.

Parameters:
element - The stack trace element object to BSONify (may be null).
Returns:
The BSONified equivalent of the stack trace element object (may be null).

bsonifyClassName

protected com.mongodb.DBObject bsonifyClassName(java.lang.String className)
BSONifies the given class name.

Parameters:
className - The class name to BSONify (may be null).
Returns:
The BSONified equivalent of the class name (may be null).

nullSafePut

protected void nullSafePut(com.mongodb.DBObject bson,
                           java.lang.String key,
                           java.lang.Object value)
Adds the given value to the given key, except if it's null (in which case this method does nothing).

Parameters:
bson - The BSON object to add the key/value to (must not be null).
key - The key of the object (must not be null).
value - The value of the object (may be null).


Copyright © 2013. All Rights Reserved.