Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/*
4
 * This file is part of the symfony package.
5
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
 
11
/**
12
 * A symfony logging adapter for Propel
13
 *
14
 * @package    symfony
15
 * @subpackage log
16
 * @author     Dustin Whittle <dustin.whittle@symfony-project.com>
17
 * @version    SVN: $Id: sfPropelLogger.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
18
 */
19
class sfPropelLogger implements BasicLogger
20
{
21
  protected
22
    $dispatcher = null;
23
 
24
  /**
25
   * Constructor.
26
   *
27
   * @param sfEventDispatcher $dispatcher
28
   */
29
  public function __construct(sfEventDispatcher $dispatcher = null)
30
  {
31
    if (null === $dispatcher)
32
    {
33
      $this->dispatcher = sfProjectConfiguration::getActive()->getEventDispatcher();
34
    }
35
    else
36
    {
37
      $this->dispatcher = $dispatcher;
38
    }
39
  }
40
 
41
  /**
42
   * A convenience function for logging an alert event.
43
   *
44
   * @param mixed $message the message to log.
45
   */
46
  public function alert($message)
47
  {
48
    $this->log($message, sfLogger::ALERT);
49
  }
50
 
51
  /**
52
   * A convenience function for logging a critical event.
53
   *
54
   * @param mixed $message the message to log.
55
   */
56
  public function crit($message)
57
  {
58
    $this->log($message, sfLogger::CRIT);
59
  }
60
 
61
  /**
62
   * A convenience function for logging an error event.
63
   *
64
   * @param mixed $message the message to log.
65
   */
66
  public function err($message)
67
  {
68
    $this->log($message, sfLogger::ERR);
69
  }
70
 
71
  /**
72
   * A convenience function for logging a warning event.
73
   *
74
   * @param mixed $message the message to log.
75
   */
76
  public function warning($message)
77
  {
78
    $this->log($message, sfLogger::WARNING);
79
  }
80
 
81
  /**
82
   * A convenience function for logging an critical event.
83
   *
84
   * @param mixed $message the message to log.
85
   */
86
  public function notice($message)
87
  {
88
    $this->log($message, sfLogger::NOTICE);
89
  }
90
 
91
  /**
92
   * A convenience function for logging an critical event.
93
   *
94
   * @param mixed $message the message to log.
95
   */
96
  public function info($message)
97
  {
98
    $this->log($message, sfLogger::INFO);
99
  }
100
 
101
  /**
102
   * A convenience function for logging a debug event.
103
   *
104
   * @param mixed $message the message to log.
105
   */
106
  public function debug($message)
107
  {
108
    $this->log($message, sfLogger::DEBUG);
109
  }
110
 
111
  /**
112
   * Primary method to handle logging.
113
   *
114
   * @param mixed $message the message to log.
115
   * @param int $severity The numeric severity. Defaults to null so that no assumptions are made about the logging backend.
116
   */
117
  public function log($message, $severity = sfLogger::DEBUG)
118
  {
119
    $this->dispatcher->notify(new sfEvent($this, 'application.log', array($message, 'priority' => $severity)));
120
  }
121
}