/usr/share/php/Analog/Handler/FirePHP.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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | <?php
namespace Analog\Handler;
/**
* Log via FirePHP using the Wildfire protocol (http://www.firephp.org/).
* Based loosely on the Monolog FirePHP handler.
*
* Usage:
*
* Analog::handler (Analog\Handler\FirePHP::init ());
*
* // send a debug message with file and line number
* Analog::log (array ('Log me', __FILE__, __LINE__), Analog::DEBUG);
*
* // send an ordinary message
* Analog::log ('An error message');
*/
class FirePHP {
/**
* Translation list for log levels.
*/
private static $log_levels = array (
\Analog\Analog::DEBUG => 'LOG',
\Analog\Analog::INFO => 'INFO',
\Analog\Analog::NOTICE => 'INFO',
\Analog\Analog::WARNING => 'WARN',
\Analog\Analog::ERROR => 'ERROR',
\Analog\Analog::CRITICAL => 'ERROR',
\Analog\Analog::ALERT => 'ERROR',
\Analog\Analog::URGENT => 'ERROR'
);
/**
* Message index increases by 1 each time a message is sent.
*/
private static $message_index = 1;
/**
* Formats a log header to be sent.
*/
public static function format_header ($info) {
if (is_array ($info['message'])) {
$extra = array (
'Type' => self::$log_levels[$info['level']],
'File' => $info['message'][1],
'Line' => $info['message'][2]
);
$info['message'] = $info['message'][0];
} else {
$extra = array ('Type' => self::$log_levels[$info['level']]);
}
$json = json_encode (array ($extra, $info['message']));
return sprintf ('X-Wf-1-1-1-%d: %s|%s|', self::$message_index++, strlen ($json), $json);
}
/**
* Sends the initial headers if FirePHP is available then returns a
* closure that handles sending log messages.
*/
public static function init () {
if (! isset ($_SERVER['HTTP_USER_AGENT'])
|| preg_match ('{\bFirePHP/\d+\.\d+\b}', $_SERVER['HTTP_USER_AGENT'])
|| isset ($_SERVER['HTTP_X_FIREPHP_VERSION'])) {
header ('X-Wf-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
header ('X-Wf-1-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3');
header ('X-Wf-1-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
}
return function ($info) {
header (FirePHP::format_header ($info));
};
}
}
|