Skip to content

Change the logging

bseddon edited this page Apr 19, 2017 · 1 revision

By default, the logging system writes log information to the PHP error log. However the logging target can be changed so you are able to write error information to a suitable target. For example, for debugging is can be useful to write log information to the console instead of or in addition to the error log. The log class include the debugLog function to do this.

Looking at this function is useful because it illustrates how change the logging targets. The XBRL_log class is a wrapper for the PEAR logging class which includes support for many logging targets.

$logConsole  = Log::singleton( 'console', '', 'console',
    array(
        'lineFormat' => '%{timestamp} [%{priority}] %{message}',
        'timeFormat' => '%Y-%m-%d %H:%M:%S',
    )
);

$logError = Log::singleton( 'error_log', PEAR_LOG_TYPE_SYSTEM, 'error_log',
    array(
        'lineFormat' => '[%{priority}] %{message}',
    )
);

$logComposite = Log::singleton( 'composite' );
$logComposite->addChild( $logConsole );
$logComposite->addChild( $logError );

$this->setLog( $logComposite );

Clone this wiki locally