Skip to content

Capture validation information

bseddon edited this page Sep 11, 2018 · 2 revisions

The information about a validation event recorded by the logging class when it writes to your choice of log output target (such as error log, console, etc.) is a single line summary of the event. There may be times when you need access to the underlying detail, perhaps so you can take action when specific events occur. We use this ability in our conformance test harness so we are able to include specific information in the conformance test result log file.

The PEAR logging system used by our XBRL processor supports the concept of an 'observer'. This is a class that has a 'notify' function the logging system can call whenever an event is logged. The class can be as simple as this:

class observer extends Log_observer
{
	public function notify( $event )
	{
		if ( ! isset( $event['source'] ) ) return;
		// Do something useful with the event detail
		$source = $event['source'];
	}
}

'source' is an array included in $event that contains the log of the XBRL validation event. The other element in $event is 'message' which is the same message written to the normal output targets.

This class can then be instantiated and passed to be attached as an observer of the XBRL processor log events:

$observer = new observer();
XBRL_Log::getInstance()->attach( $observer );
Clone this wiki locally