/usr/share/php/Analog/Handler/Multi.php is in php-analog 1.0.7-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <?php
namespace Analog\Handler;
/**
* Sends messages to one or more of the other handlers based on its
* log level.
*
* Usage:
*
* Analog::handler( Analog\Handler\Multi::init( array(
* // anything error or worse goes to this
* Analog::ERROR => array(
* Analog\Handler\Mail::init( $to, $subject, $from ),
* Analog\Handler\Stderr::init()
* ),
*
* // Warnings are sent here
* Analog::WARNING => Analog\Handler\File::init( 'logs/warnings.log' ),
*
* // Debug and info messages sent here
* Analog::DEBUG => Analog\Handler\Ignore::init() // do nothing
* ) ) );
*
* // will be ignored
* Analog::log ('Ignore me', Analog::DEBUG);
*
* // will be written to logs/warnings.log
* Analog::log ('Log me', Analog::WARNING);
*
* // will trigger an email notice
* Analog::log ('Uh oh...', Analog::ERROR);
*/
class Multi {
public static function init ($handlers) {
return function ($info) use ($handlers) {
$level = is_numeric ($info['level']) ? $info['level'] : 3;
while ($level <= 7) {
if ( isset ( $handlers[ $level ] ) ) {
if ( ! is_array( $handlers[ $level ] ) ) {
$handlers[ $level ] = array( $handlers[ $level ] );
}
foreach ( $handlers[ $level ] as $handler ) {
$handler( $info );
}
return;
}
$level++;
}
};
}
}
|