|
Revision 17858, 1.5 kB
(checked in by FabianLange, 4 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 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 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 |
|
|---|