Skip to content
Barry O'Donovan edited this page Nov 19, 2012 · 2 revisions

OSS_Logger is a load on demand resource as opposed to Zend's logger resource which is always loaded whether used or now.

It is configured almost identically to the Zend_Logger resource. Here's a real example:

ondemand_resources.logger.enabled = 1
ondemand_resources.logger.writers.email.from = [email protected]
ondemand_resources.logger.writers.email.to = [email protected]
ondemand_resources.logger.writers.email.prefix = 'APP_Error'
ondemand_resources.logger.writers.email.level = 3
ondemand_resources.logger.writers.stream.level = 7
ondemand_resources.logger.writers.stream.path = APPLICATION_PATH "/../var/log"
ondemand_resources.logger.writers.stream.owner = www-data
ondemand_resources.logger.writers.stream.group = www-data

You then use the following trait:

use OSS_Controller_Action_Trait_Logger;

where after, any time that is required in your application controllers, you can create a log message using any of:

$this->getLogger()->emerg( 'log message' );
$this->getLogger()->alert( 'log message' );
$this->getLogger()->crit( 'log message' );
$this->getLogger()->err( 'log message' );
$this->getLogger()->warn( 'log message' );
$this->getLogger()->notice( 'log message' );
$this->getLogger()->info( 'log message' );
$this->getLogger()->debug( 'log message' );

When getLogger() is called, the logger is only then instantiated if not already done.

You can also log via:

$this->getLogger()->log( 'log message', OSS_Logger::EMERG|ALERT|CRIT|ERR|WARN|NOTICE|INFO|DEBUG );

Stream Directories and Files

The OSS_Logger will layout the log structure as YYYY/MM/YYYYMMDD.log and it will try and create these directories under ondemand_resources.logger.writers.stream.path.

Clone this wiki locally