Skip to content
This repository has been archived by the owner on Nov 13, 2017. It is now read-only.

havvg/sfMongoDBLoggerPlugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

sfMongoDBLoggerPlugin

The sfMongoDBLogger uses a MongoDB to log messages. It utilizes several features of the mongo extension and MongoDB itself.

Configuration

There are several configuration options available.

Server configuration

The basic configuration items to initialize a working MongoDB connection.

  • host, defaults to configured PHP host
  • port, defaults to configured PHP port

These two options are required in order to get the logger working:

  • database
  • collection

Authentication configuration

If you want to connect to the MongoDB as an authenticated user, you can put the information in these items. To disable this feature, configure it with false (default).

  • username
  • password

MongoDB write options

By default the write operations on MongoDB are not synchronous. This implies that not all data sent to the server will actually be written to the persistent, in case something bad happens. However there are options to force the server to actually persist the data before returning the result state.

The option save takes three keys. (see http://docs.php.net/manual/en/mongocollection.insert.php)

  • safe
  • fsync
  • timeout

Each of these options default to the extensions default settings, but can be overwritten on a per logger basis. This way you can add an error logger with synchronous write operations while having a debug logger without.

MongoDB create collection options

By default MongoDB creates a collection on-the-fly where needed. If you want to create a collection with different parameters than the default ones, e.g. a capped collection, you can specify these options using the create option.

This option takes these keys. (see http://docs.php.net/manual/en/mongodb.createcollection.php)

  • capped
  • size
  • max

Example Configuration

  logger:
    class: sfMongoDBLogger
    param:
      level: debug
      
      # The MongoDB server
      host: <?php echo Mongo::DEFAULT_HOST . "\n" ?>
      port: <?php echo Mongo::DEFAULT_PORT . "\n" ?>
      database: ~
      collection: ~
      
      # Authentication information
      username: false
      password: false
        
      # Options passed when inserting a new document
      save:
        safe: false
        fsync: false
        timeout: <?php echo MongoCursor::$timeout . "\n" ?>

      # Options to create the collection.
      create:
        capped: false
        size: 0
        max: 0

Events

mongodblog

mongodblog.pre_insert

Notify method: filter

Default notifiers: sfMongoDBLogger

This event passes the document (associative array: message, priority) to be inserted into MongoDB for further modification.

The following listeners are bundled and can be connected to this event.

  • sfMongoDBLoggerListener::addTimestamp
  • sfMongoDBLoggerListener::convertLogPriority

About

An sfLogger implementation using MongoDB server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages