Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
$log = Zend_Registry::get('logger');
/* @var $log ZfExtendend_Logger */
$log->error("TODO"); // logs an error
// must be enabled in the filters
$log->debug("TODO"); // logs a debug statement
$log->trace("TODO"); // logs a debug statement with stack trace
$log->logDev($data1, $data2, ...); // a convienent replacement for error_log(print_r($data, 1)); Only for development, should not be comitted!

// the WorkflowLogger - dedicated to translate5 tasks and workflow stuff - must be instanced manually:
// TODO


Use the ZfExtended_Logger_DebugTrait for debugging

The ZfExtended_Logger_DebugTrait provides a reusable, unified way to get a logger instance into a class for logging and debugging.

Example:

Code Block
class Class_Or_Plugin_In_Which_I_Want_To_Log {
    use ZfExtended_Logger_DebugTrait; //→ use the debug trait to get several things

	public function __construct() {
		//before first usage init the logger:
        $this->initLogger('E1100', 'plugin.name.special.sub.stuff', 'plugin.name', 'Plug-In NAME: ');
		//	E1100 → specific error code for the domain to be logged (or general code if applicable)
		//	plugin.name.special.sub.stuff → the domain of the current scope to be logged
		//  plugin.name → the root domain which is used as check in the logger writer configuration. If this string occurs somewhere in the writer domain filters, the debug and trace function will do something
		//  Plug-In NAME: → a string prefix which is added to each debug and trace message.
    }

	public function doSomethingToUseTheLogger() {
		$this->log->warn("EXXXX", "Message", ['data' => 123]);  // by the trait $this->log is initialized with a logger using the domain "plugin.name.special.sub.stuff"
		$this->debug('Debug message', ['debugdata' => 123]);    // the trait provides the debug function, which uses the above configured ECode and prefix. Also it uses the configured domain. 
																// this debug statement can remain in the code. 
																// It will only do something if one of the log writers is configured with a filter with a domain containing 'plugin.name' and level debug
																// so multiple debug statements should not pull down the performance and will not waste the log by the default
		$this->trace('Message', ['debugdata' => 123]);			// basicly the same as debug() but with complete stack trace in the log. filter level must be trace so that this functions is soing something.
    }


TODO

Exception Definition / Usage:

...