Development

/branches/1.2/lib/command/sfCommandLogger.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/command/sfCommandLogger.class.php

Revision 17858, 1.5 kB (checked in by FabianLange, 6 years ago)

[1.1, 1.2, 1.3] fixed some codeing standards (fixes #6376 - patch from gimler)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
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  *
13  * @package    symfony
14  * @subpackage log
15  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
16  * @version    SVN: $Id$
17  */
18 class sfCommandLogger extends sfConsoleLogger
19 {
20   /**
21    * Initializes this logger.
22    *
23    * @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
24    * @param array             $options    An array of options.
25    */
26   public function initialize(sfEventDispatcher $dispatcher, $options = array())
27   {
28     $dispatcher->connect('command.log', array($this, 'listenToLogEvent'));
29
30     return parent::initialize($dispatcher, $options);
31   }
32
33   /**
34    * Listens to command.log events.
35    *
36    * @param sfEvent $event An sfEvent instance
37    */
38   public function listenToLogEvent(sfEvent $event)
39   {
40     $priority = isset($event['priority']) ? $event['priority'] : self::INFO;
41
42     $prefix = '';
43     if ('application.log' == $event->getName())
44     {
45       $subject  = $event->getSubject();
46       $subject  = is_object($subject) ? get_class($subject) : (is_string($subject) ? $subject : 'main');
47
48       $prefix = '>> '.$subject.' ';
49     }
50
51     foreach ($event->getParameters() as $key => $message)
52     {
53       if ('priority' === $key)
54       {
55         continue;
56       }
57
58       $this->log(sprintf('%s%s', $prefix, $message), $priority);
59     }
60   }
61 }
62
Note: See TracBrowser for help on using the browser.