This file is indexed.

/usr/share/php/Analog/Handler/LevelBuffer.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
<?php

namespace Analog\Handler;

/**
 * Buffers messages to be sent as a batch to another handler only when a
 * message of a certain level threshold has been received. This means for
 * example that you can trigger a handler only if an error has occurred.
 * Currently only works with the Mail handler.
 *
 * Inspired by the Monolog FingersCrossedHandler.
 *
 * Usage:
 *
 *     Analog::handler (Analog\Handler\LevelBuffer::init (
 *         Analog\Handler\Mail::init ($to, $subject, $from),
 *         Analog::ERROR
 *     ));
 *     
 *     // will all be buffered until something ERROR or above is logged
 *     Analog::log ('Message one', Analog::DEBUG);
 *     Analog::log ('Message two', Analog::WARNING);
 *     Analog::log ('Message three', Analog::URGENT);
 *
 * Note: Uses Analog::$format to format the messages as they're appended
 * to the buffer.
 */
class LevelBuffer {
	/**
	 * This builds a log string of all messages logged.
	 */
	public static $buffer = '';

	/**
	 * This contains the handler to send to on close.
	 */
	private static $handler;

	/**
	 * Accepts another handler function to be used on close().
	 * $until_level defaults to CRITICAL.
	 */
	public static function init ($handler, $until_level = 2) {
		self::$handler = $handler;

		return function ($info) use ($until_level) {
			LevelBuffer::$buffer .= vsprintf (\Analog\Analog::$format, $info);
			if ($info['level'] <= $until_level) {
				// flush and reset the buffer
				LevelBuffer::flush ();
				LevelBuffer::$buffer = '';
			}
		};
	}

	/**
	 * Passes the buffered log to the final $handler.
	 */
	public static function flush () {
		$handler = self::$handler;
		return $handler (self::$buffer, true);
	}
}