~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Log/Filter/Priority.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Zend Framework
 
4
 *
 
5
 * LICENSE
 
6
 *
 
7
 * This source file is subject to the new BSD license that is bundled
 
8
 * with this package in the file LICENSE.txt.
 
9
 * It is also available through the world-wide-web at this URL:
 
10
 * http://framework.zend.com/license/new-bsd
 
11
 * If you did not receive a copy of the license and are unable to
 
12
 * obtain it through the world-wide-web, please send an email
 
13
 * to license@zend.com so we can send you a copy immediately.
 
14
 *
 
15
 * @category   Zend
 
16
 * @package    Zend_Log
 
17
 * @subpackage Filter
 
18
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
20
 * @version    $Id: Priority.php 8064 2008-02-16 10:58:39Z thomas $
 
21
 */
 
22
 
 
23
/** Zend_Log_Filter_Interface */
 
24
require_once 'Zend/Log/Filter/Interface.php';
 
25
 
 
26
/**
 
27
 * @category   Zend
 
28
 * @package    Zend_Log
 
29
 * @subpackage Filter
 
30
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
31
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
32
 * @version    $Id: Priority.php 8064 2008-02-16 10:58:39Z thomas $
 
33
 */
 
34
class Zend_Log_Filter_Priority implements Zend_Log_Filter_Interface
 
35
{
 
36
    /**
 
37
     * @var integer
 
38
     */
 
39
    protected $_priority;
 
40
 
 
41
    /**
 
42
     * @var string
 
43
     */
 
44
    protected $_operator;
 
45
 
 
46
    /**
 
47
     * Filter logging by $priority.  By default, it will accept any log
 
48
     * event whose priority value is less than or equal to $priority.
 
49
     *
 
50
     * @param  integer  $priority  Priority
 
51
     * @param  string   $operator  Comparison operator
 
52
     * @throws Zend_Log_Exception
 
53
     */
 
54
    public function __construct($priority, $operator = '<=')
 
55
    {
 
56
        if (! is_integer($priority)) {
 
57
            throw new Zend_Log_Exception('Priority must be an integer');
 
58
        }
 
59
 
 
60
        $this->_priority = $priority;
 
61
        $this->_operator = $operator;
 
62
    }
 
63
 
 
64
    /**
 
65
     * Returns TRUE to accept the message, FALSE to block it.
 
66
     *
 
67
     * @param  array    $event    event data
 
68
     * @return boolean            accepted?
 
69
     */
 
70
    public function accept($event)
 
71
    {
 
72
        return version_compare($event['priority'], $this->_priority, $this->_operator);
 
73
    }
 
74
 
 
75
}