1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- class sfCommandLogger extends sfConsoleLogger
- {
-
- public function initialize(sfEventDispatcher $dispatcher, $options = array())
- {
- $dispatcher->connect('command.log', array($this, 'listenToLogEvent'));
- return parent::initialize($dispatcher, $options);
- }
-
- public function listenToLogEvent(sfEvent $event)
- {
- $priority = isset($event['priority']) ? $event['priority'] : self::INFO;
- $prefix = '';
- if ('application.log' == $event->getName())
- {
- $subject = $event->getSubject();
- $subject = is_object($subject) ? get_class($subject) : (is_string($subject) ? $subject : 'main');
- $prefix = '>> '.$subject.' ';
- }
- foreach ($event->getParameters() as $key => $message)
- {
- if ('priority' === $key)
- {
- continue;
- }
- $this->log(sprintf('%s%s', $prefix, $message), $priority);
- }
- }
- }
|