1. sfCommandLogger.class.php
  2. /** * * @package symfony * @subpackage log * @author Fabien Potencier * @version SVN: $Id: sfCommandLogger.class.php 17865 2009-05-02 09:23:55Z FabianLange $ */
  3. class sfCommandLogger extends sfConsoleLogger
  4. {
  5. /**
  6. * Initializes this logger.
  7. *
  8. * @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
  9. * @param array $options An array of options.
  10. */
  11. public function initialize(sfEventDispatcher $dispatcher, $options = array())
  12. {
  13. $dispatcher->connect('command.log', array($this, 'listenToLogEvent'));
  14. return parent::initialize($dispatcher, $options);
  15. }
  16. /**
  17. * Listens to command.log events.
  18. *
  19. * @param sfEvent $event An sfEvent instance
  20. */
  21. public function listenToLogEvent(sfEvent $event)
  22. {
  23. $priority = isset($event['priority']) ? $event['priority'] : self::INFO;
  24. $prefix = '';
  25. if ('application.log' == $event->getName())
  26. {
  27. $subject = $event->getSubject();
  28. $subject = is_object($subject) ? get_class($subject) : (is_string($subject) ? $subject : 'main');
  29. $prefix = '>> '.$subject.' ';
  30. }
  31. foreach ($event->getParameters() as $key => $message)
  32. {
  33. if ('priority' === $key)
  34. {
  35. continue;
  36. }
  37. $this->log(sprintf('%s%s', $prefix, $message), $priority);
  38. }
  39. }
  40. }

Debug toolbar