/usr/share/php/Analog/Handler/GELF.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 | <?php
namespace Analog\Handler;
/**
* Send the log message to a Graylog2 server (http://graylog2.org/).
*
* Usage:
*
* // First include the GELF classes from
* // https://github.com/Graylog2/gelf-php
* require 'GELFMessage.php';
* require 'GELFMessagePublisher.php';
*
* // Initialize the Analog GELF handler
* Analog::handler (Analog\Handler\GELF::init (
* '172.16.22.30'
* ));
*
* // Send a 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 GELF {
public static function init ($host = '127.0.0.1', $port = \GELFMessagePublisher::GRAYLOG2_DEFAULT_PORT) {
$publisher = new \GELFMessagePublisher ($host, $port);
return function ($info) use ($publisher) {
$message = new \GELFMessage ();
$message->setHost ($info['machine']);
$message->setLevel ($info['level']);
if (is_array ($info['message'])) {
$message->setShortMessage ($info['message'][0]);
$message->setFullMessage ($info['message'][0]);
$message->setFile ($info['message'][1]);
$message->setLine ($info['message'][2]);
} else {
$message->setShortMessage ($info['message']);
$message->setFullMessage ($info['message']);
}
$publisher->publish ($message);
};
}
}
|