/usr/share/php/Analog/Handler/Buffer.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 | <?php
namespace Analog\Handler;
/**
* Buffers messages to be sent as a batch to another handler at the end
* of the request. Currently only works with the Mail handler.
*
* Usage:
*
* Analog::handler (Analog\Handler\Buffer::init (
* Analog\Handler\Mail::init ($to, $subject, $from)
* ));
*
* // will all be buffered into one email
* Analog::log ('Message one', Analog::DEBUG);
* Analog::log ('Message two', Analog::WARNING);
* Analog::log ('Message three', Analog::ERROR);
*
* Note: Uses Analog::$format to format the messages as they're appended
* to the buffer.
*/
class Buffer {
/**
* This builds a log string of all messages logged.
*/
public static $buffer = '';
/**
* This contains the handler to send to on close.
*/
private static $handler;
/**
* A copy of our destructor object that will call close() on our behalf,
* since static classes can't have their own __destruct() methods.
*/
private static $destructor;
/**
* Accepts another handler function to be used on close().
*/
public static function init ($handler) {
self::$handler = $handler;
self::$destructor = new \Analog\Handler\Buffer\Destructor ();
return function ($info) {
Buffer::$buffer .= vsprintf (\Analog\Analog::$format, $info);
};
}
/**
* Passes the buffered log to the final $handler.
*/
public static function close () {
$handler = self::$handler;
return $handler (self::$buffer, true);
}
}
|