<?php require '../lib/Analog.php'; $log = ''; Analog::handler(Analog\Handler\LevelBuffer::init(Analog\Handler\Variable::init($log), Analog::CRITICAL)); // none of these will trigger sending the log Analog::log('Debugging...', Analog::DEBUG); Analog::log('Minor warning...', Analog::WARNING); Analog::log('An error...', Analog::ERROR); echo "Log is still empty:\n" . $log . "\n"; // but this will, and will include all the others in the log Analog::log('Oh noes!', Analog::URGENT); echo "Log now has everything:\n" . $log;
<?php require '../lib/Analog.php'; $log = ''; Analog::handler(Analog\Handler\Variable::init($log)); Analog::log('foo'); Analog::log('bar'); echo $log;
<?php require '../lib/Analog.php'; $log = ''; Analog::handler(Analog\Handler\Threshold::init(Analog\Handler\Variable::init($log), Analog::ERROR)); // these will be ignored Analog::log('Debugging...', Analog::DEBUG); Analog::log('Minor warning...', Analog::WARNING); echo "Log is still empty:\n" . $log . "\n"; // but these will be logged Analog::log('An error...', Analog::ERROR); Analog::log('Oh noes!', Analog::URGENT); echo "Log now has everything:\n" . $log;
<?php require '../lib/Analog.php'; $errors = "Errors:\n"; $warnings = "Warnings:\n"; $debug = "Debug:\n"; Analog::handler(Analog\Handler\Multi::init(array(Analog::ERROR => Analog\Handler\Variable::init($errors), Analog::WARNING => Analog\Handler\Variable::init($warnings), Analog::DEBUG => Analog\Handler\Variable::init($debug)))); Analog::log('First error'); Analog::log('Emergency!', Analog::URGENT); Analog::log('A warning...', Analog::WARNING); Analog::log('Some info', Analog::INFO); Analog::log('Debugging output', Analog::DEBUG); echo $errors; echo "-----\n"; echo $warnings; echo "-----\n"; echo $debug;