Plop
A simple logging library for PHP
Level.php
1 <?php
2 /*
3  This file is part of Plop, a simple logging library for PHP.
4 
5  Copyright © 2010-2014 François Poirotte
6 
7  Plop is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Plop is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Plop. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 namespace Plop\Filter;
22 
28 class Level implements \Plop\FilterInterface
29 {
31  protected $level;
32 
40  public function __construct($level)
41  {
42  if (is_string($level)) {
43  $plop = \Plop\Plop::getInstance();
45  }
46  if (!is_int($level)) {
47  throw new \Plop\Exception('Invalid value');
48  }
49  $this->level = $level;
50  }
51 
53  public function filter(\Plop\RecordInterface $record)
54  {
55  $res = $record['levelno'] >= $this->level;
56  return $res;
57  }
58 }
Interface for a log record.
static & getInstance()
Definition: Plop.php:195
A filter that only accepts records from a specific logger.
Definition: Level.php:28
$level
Minimal log level that will be accepted (inclusive).
Definition: Level.php:31
__construct($level)
Definition: Level.php:40
getLevelValue($levelName)
Definition: Plop.php:283
filter(\Plop\RecordInterface $record)
Definition: Level.php:53
Interface for a filter.