Class LoggerAppenderMongoDB

Description

Appender for writing to MongoDB.

This class was originally contributed by Vladimir Gorej.

Located in /appenders/LoggerAppenderMongoDB.php (line 34)

LoggerConfigurable
   |
   --LoggerAppender
      |
      --LoggerAppenderMongoDB
Class Constant Summary
 DEFAULT_DB_NAME = 'log4php_mongodb'
 DEFAULT_MONGO_HOST = 'localhost'
 DEFAULT_MONGO_URL_PREFIX = 'mongodb://'
Variable Summary
mixed $canAppend
MongoCollection $collection
Mongo $connection
mixed $host
mixed $password
mixed $port
mixed $timeout
mixed $userName
Method Summary
LoggerAppenderMongoDB __construct ([ $name = ''])
void activateOptions ()
void append (LoggerLoggingEvent $event)
void close ()
array format (LoggerLoggingEvent $event)
array formatThrowable ( $ex)
MongoCollection getCollection ()
Mongo getConnection ()
void getDatabaseName ()
void getHost ()
void getPassword ()
void getPort ()
void getTimeout ()
void getUserName ()
void setCollectionName ( $collectionName)
void setDatabaseName ( $databaseName)
void setHost ( $host)
void setPassword ( $password)
void setPort ( $port)
void setTimeout ( $timeout)
void setUserName ( $userName)
Variables
mixed $canAppend = false (line 103)

Set to true if the appender can append.

  • todo: Maybe we should use $closed here instead?
  • access: protected
MongoCollection $collection (line 97)

The collection to which log is written.

  • access: protected
mixed $collectionName (line 72)

Name of the collection within the given database.

  • access: protected
Mongo $connection (line 91)

Connection to the MongoDB instance.

  • access: protected
mixed $databaseName (line 69)

Name of the database to which to log.

  • access: protected
mixed $host (line 63)

Server on which mongodb instance is located.

  • access: protected
mixed $password (line 78)

Password used to connect to the database.

  • access: protected
mixed $port (line 66)

Port on which the instance is bound.

  • access: protected
mixed $requiresLayout = false (line 106)

Appender does not require a layout.

  • access: protected

Redefinition of:
LoggerAppender::$requiresLayout
Set to true if the appender requires a layout.
mixed $timeout (line 81)

Timeout value used when connecting to the database (in milliseconds).

  • access: protected
mixed $userName (line 75)

Username used to connect to the database.

  • access: protected

Inherited Variables

Inherited from LoggerAppender

LoggerAppender::$closed
LoggerAppender::$filter
LoggerAppender::$layout
LoggerAppender::$name
LoggerAppender::$threshold
Methods
Constructor __construct (line 108)
  • access: public
LoggerAppenderMongoDB __construct ([ $name = ''])
  • $name

Redefinition of:
LoggerAppender::__construct()
Default constructor.
activateOptions (line 124)

Setup db connection.

Based on defined options, this method connects to the database and creates a $collection.

  • throws: Exception if the attempt to connect to the requested database fails.
  • access: public
void activateOptions ()

Redefinition of:
LoggerAppender::activateOptions()
Prepares the appender for logging.
append (line 149)

Appends a new event to the mongo database.

  • throws: LoggerException If the pattern conversion or the INSERT statement fails.
  • access: public
void append (LoggerLoggingEvent $event)

Redefinition of:
LoggerAppender::append()
Forwards the logging event to the destination.
close (line 215)

Closes the connection to the logging database

  • access: public
void close ()

Redefinition of:
LoggerAppender::close()
Releases any resources allocated by the appender.
format (line 162)

Converts the logging event into an array which can be logged to mongodb.

  • return: The array representation of the logging event.
  • access: protected
array format (LoggerLoggingEvent $event)
formatThrowable (line 198)

Converts an Exception into an array which can be logged to mongodb.

Supports innner exceptions (PHP >= 5.3)

  • access: protected
array formatThrowable ( $ex)
  • Exception $ex
getCollection (line 310)

Returns the active mongodb collection.

  • access: public
MongoCollection getCollection ()
getCollectionName (line 265)

Returns the value of $collectionName parameter.

  • access: public
void getCollectionName ()
getConnection (line 302)

Returns the mongodb connection.

  • access: public
Mongo getConnection ()
getDatabaseName (line 255)

Returns the value of $databaseName parameter.

  • access: public
void getDatabaseName ()
getHost (line 235)

Returns the value of $host parameter.

  • access: public
void getHost ()
getPassword (line 285)

Returns the value of $password parameter.

  • access: public
void getPassword ()
getPort (line 245)

Returns the value of $port parameter.

  • access: public
void getPort ()
getTimeout (line 295)

Returns the value of $timeout parameter.

  • access: public
void getTimeout ()
getUserName (line 275)

Returns the value of $userName parameter.

  • access: public
void getUserName ()
setCollectionName (line 260)

Sets the value of $collectionName parameter.

  • access: public
void setCollectionName ( $collectionName)
  • $collectionName
setDatabaseName (line 250)

Sets the value of $databaseName parameter.

  • access: public
void setDatabaseName ( $databaseName)
  • $databaseName
setHost (line 227)

Sets the value of $host parameter.

  • access: public
void setHost ( $host)
  • $host
setPassword (line 280)

Sets the value of $password parameter.

  • access: public
void setPassword ( $password)
  • $password
setPort (line 240)

Sets the value of $port parameter.

  • access: public
void setPort ( $port)
  • $port
setTimeout (line 290)

Sets the value of $timeout parameter.

  • access: public
void setTimeout ( $timeout)
  • $timeout
setUserName (line 270)

Sets the value of $userName parameter.

  • access: public
void setUserName ( $userName)
  • $userName

Inherited Methods

Inherited From LoggerAppender

LoggerAppender::__construct()
LoggerAppender::activateOptions()
LoggerAppender::addFilter()
LoggerAppender::append()
LoggerAppender::clearFilters()
LoggerAppender::close()
LoggerAppender::doAppend()
LoggerAppender::getDefaultLayout()
LoggerAppender::getFilter()
LoggerAppender::getFirstFilter()
LoggerAppender::getLayout()
LoggerAppender::getName()
LoggerAppender::getThreshold()
LoggerAppender::isAsSevereAsThreshold()
LoggerAppender::requiresLayout()
LoggerAppender::setLayout()
LoggerAppender::setName()
LoggerAppender::setThreshold()
LoggerAppender::warn()

Inherited From LoggerConfigurable

LoggerConfigurable::setBoolean()
LoggerConfigurable::setFileSize()
LoggerConfigurable::setInteger()
LoggerConfigurable::setLevel()
LoggerConfigurable::setNumeric()
LoggerConfigurable::setPositiveInteger()
LoggerConfigurable::setString()
LoggerConfigurable::warn()
Class Constants
DEFAULT_COLLECTION_NAME = 'logs' (line 53)

Default value for $collectionName

DEFAULT_DB_NAME = 'log4php_mongodb' (line 50)

Default value for $databaseName

DEFAULT_MONGO_HOST = 'localhost' (line 44)

Default value for $host, without a prefix.

DEFAULT_MONGO_PORT = 27017 (line 47)

Default value for $port

DEFAULT_MONGO_URL_PREFIX = 'mongodb://' (line 41)

Default prefix for the $host.

DEFAULT_TIMEOUT_VALUE = 3000 (line 56)

Default value for $timeout

Documentation generated on Sat, 18 Feb 2012 22:32:22 +0000 by phpDocumentor 1.4.3