This file is indexed.

/usr/share/php/Horde/Log/Logger.php is in php-horde-log 2.2.0-2.

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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?php
/**
 * Horde Log package
 *
 * This package is based on Zend_Log from the Zend Framework
 * (http://framework.zend.com).  Both that package and this
 * one were written by Mike Naberezny and Chuck Hagenbuch.
 *
 * @author   Mike Naberezny <mike@maintainable.com>
 * @author   Chuck Hagenbuch <chuck@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/bsd BSD
 * @package  Log
 */

/**
 * @author   Mike Naberezny <mike@maintainable.com>
 * @author   Chuck Hagenbuch <chuck@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/bsd BSD
 * @package  Log
 *
 * @method void LOGLEVEL() LOGLEVEL($event) Log an event at LOGLEVEL, where LOGLEVEL has been added with addLevel() or already exists
 * @method void emerg() emerg($event) Log an event at the EMERG log level
 * @method void alert() alert($event) Log an event at the ALERT log level
 * @method void crit() crit($event) Log an event at the CRIT log level
 * @method void err() err($event) Log an event at the ERR log level
 * @method void warn() warn($event) Log an event at the WARN log level
 * @method void notice() notice($event) Log an event at the NOTICE log level
 * @method void info() info($event) Log an event at the INFO log level
 * @method void debug() debug($event) Log an event at the DEBUG log level
 */
class Horde_Log_Logger implements Serializable
{
    /* Serialize version. */
    const VERSION = 1;

    /**
     * Log levels where the keys are the level priorities and the values are
     * the level names.
     *
     * @var array
     */
    private $_levels = array();

    /**
     * Horde_Log_Handler_Base objects.
     *
     * @var array
     */
    private $_handlers = array();

    /**
     * Horde_Log_Filter objects.
     *
     * @var array
     */
    private $_filters = array();

    /**
     * Constructor.
     *
     * @param Horde_Log_Handler_Base|null $handler  Default handler.
     */
    public function __construct($handler = null)
    {
        if (!is_null($handler)) {
            $this->addHandler($handler);
        }

        $this->_init();
    }

    /**
     * Serialize.
     *
     * @return string  Serialized representation of this object.
     */
    public function serialize()
    {
        return serialize(array(
            self::VERSION,
            $this->_filters,
            $this->_handlers
        ));
    }

    /**
     * Unserialize.
     *
     * @param string $data  Serialized data.
     *
     * @throws Exception
     */
    public function unserialize($data)
    {
        $data = @unserialize($data);
        if (!is_array($data) ||
            !isset($data[0]) ||
            ($data[0] != self::VERSION)) {
            throw new Exception('Cache version change');
        }

        $this->_filters = $data[1];
        $this->_handlers = $data[2];

        $this->_init();
    }

    /**
     * Initialization tasks.
     */
    protected function _init()
    {
        $r = new ReflectionClass('Horde_Log');
        $this->_levels = $r->getConstants();
    }

    /**
     * Undefined method handler allows a shortcut:
     * <pre>
     * $log->levelName('message');
     *   instead of
     * $log->log('message', Horde_Log_LEVELNAME);
     * </pre>
     *
     * @param string $method  Log level name.
     * @param string $params  Message to log.
     */
    public function __call($method, $params)
    {
        $levelName = Horde_String::upper($method);
        if (isset($this->_levels[$levelName])) {
            $this->log(array_shift($params), $this->_levels[$levelName]);
        } else {
            throw new Horde_Log_Exception('Bad log level ' . $levelName);
        }
    }

    /**
     * Log a message at a level
     *
     * @param mixed $event    Message to log, either an array or a string.
     * @param integer $level  Log level of message, required if $message is a
     *                        string.
     */
    public function log($event, $level = null)
    {
        if (empty($this->_handlers)) {
            throw new Horde_Log_Exception('No handlers were added');
        }

        // Create an event array from the given arguments.
        if (is_array($event)) {
            // If we are passed an array, it must contain 'message'
            // and 'level' indices.
            if (!isset($event['message'])) {
                throw new Horde_Log_Exception('Event array did not contain a message');
            }
            if (!isset($event['level'])) {
                if (is_null($level)) {
                    throw new Horde_Log_Exception('Event array did not contain a log level');
                }
                $event['level'] = $level;
            }
        } else {
            // Create an event array from the message and level
            // arguments.
            $event = array('message' => $event, 'level' => $level);
        }

        if (($level = array_search($event['level'], $this->_levels)) === false) {
            throw new Horde_Log_Exception('Bad log level: ' . $event['level']);
        }

        // Fill in the level name and timestamp for filters, formatters,
        // handlers.
        $event['levelName'] = $level;

        if (!isset($event['timestamp'])) {
            $event['timestamp'] = date('c');
        }

        // If any global filter rejects the event, don't log it.
        foreach ($this->_filters as $filter) {
            if (!$filter->accept($event)) {
                return;
            }
        }

        foreach ($this->_handlers as $handler) {
            $handler->log($event);
        }
    }

    /**
     * Does this logger have the level $name already?
     *
     * @param string $name  The level name to check for.
     *
     * @return boolean  Whether the logger already has the specific level
     *                  name.
     */
    public function hasLevel($name)
    {
        return isset($this->_levels[$name]);
    }

    /**
     * Add a custom log level
     *
     * @param string $name    Name of level.
     * @param integer $level  Numeric level.
     */
    public function addLevel($name, $level)
    {
        // Log level names must be uppercase for predictability.
        $name = Horde_String::upper($name);

        if ($this->hasLevel($name)) {
            throw new Horde_Log_Exception('Existing log levels cannot be overwritten');
        }

        $this->_levels[$name] = $level;
    }

    /**
     * Add a filter that will be applied before all log handlers.
     * Before a message will be received by any of the handlers, it
     * must be accepted by all filters added with this method.
     *
     * @param Horde_Log_Filter $filter  Filter to add.
     */
    public function addFilter($filter)
    {
        $this->_filters[] = is_integer($filter)
            ? new Horde_Log_Filter_Level($filter)
            : $filter;
    }

    /**
     * Add a handler.  A handler is responsible for taking a log
     * message and writing it out to storage.
     *
     * @param Horde_Log_Handler_Base $handler  Handler to add.
     */
    public function addHandler($handler)
    {
        $this->_handlers[] = $handler;
    }

}