public function process(AMQPMessage $message)
 {
     $handlers = $this->logger->getHandlers();
     if (empty($handlers)) {
         throw new \Exception('No handlers registered');
     }
     $this->logger->critical($message->body);
     $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
 }
Exemplo n.º 2
0
 public function testErrorLogHandlerAssertions()
 {
     $handlers = $this->log->getHandlers();
     $hasErrorHandler = false;
     foreach ($handlers as $handler) {
         if (!$handler instanceof ErrorLogHandler) {
             continue;
         }
         $hasErrorHandler = true;
         $this->assertEquals(Logger::ERROR, $handler->getLevel());
     }
     $this->assertTrue($hasErrorHandler);
 }
 public function testRollbackLogsProfileData()
 {
     $this->pdo->beginTransaction();
     $this->pdo->rollBack();
     /** @var TestHandler $handler */
     $handlers = $this->logger->getHandlers();
     $handler = $handlers[0];
     $this->assertTrue($handler->hasDebugThatContains('rollBack'));
 }
Exemplo n.º 4
0
 /**
  * Initialize
  *
  * Initilize monolog instance. Singleton
  * Is possbile provide an external monolog instance
  *
  * @param \Monolog\Logger
  *
  * @return \Monolog\Logger
  */
 public static function initialize(Logger $external_monolog = null)
 {
     if (self::$monolog === null) {
         if ($external_monolog !== null) {
             self::$monolog = $external_monolog;
             foreach (self::$monolog->getHandlers() as $handler) {
                 if ($handler->getLevel() == 400) {
                     self::$error_log_path = true;
                 }
                 if ($handler->getLevel() == 100) {
                     self::$debug_log_path = true;
                 }
             }
         } else {
             self::$monolog = new Logger('bot_log');
         }
     }
     return self::$monolog;
 }
Exemplo n.º 5
0
 public function testRecordStructureForException()
 {
     $pushbullet = Mockery::mock('pushbullet');
     $pushbullet->shouldReceive('user->note')->once();
     $logger = new Logger('MonobulletTest');
     $logger->pushHandler(new Handler($pushbullet, null));
     $logger->info('exception \'ErrorException\' with message \'Undefined property: stdClass::$dummy\' in /tmp/non-existant.php:27' . PHP_EOL . 'Stack trace:' . PHP_EOL . '#0 /tmp/04227d.php(27): HandleExceptions->handleError(8, \'Undefined prope...\', \'/tmp/non-exi...\', 27, Array)' . PHP_EOL . '#1 /tmp/AnotherDummy.php(42): include(\'/tmp/non-exis...\')' . PHP_EOL . '#2 /tmp/WowStillDummy.php(59): Method->DumDum(\'/tmp/che...\', Array)');
     $record = $logger->getHandlers()[0]->getLastRecord();
     $this->assertArrayHasKey('formatted', $record);
     $this->assertArrayHasKey('title', $record['formatted']);
     $this->assertArrayHasKey('stack', $record['formatted']['extra']);
 }
Exemplo n.º 6
0
 /**
  * Get logger.
  *
  * @return null|LoggerInterface
  */
 public function getLogger()
 {
     if (null === $this->logger) {
         $logger = new Logger(Commander::LOGGER_NAME);
         foreach ($this->getHandlers() as $handler) {
             $logger->pushHandler($handler);
         }
         if (0 === count($logger->getHandlers())) {
             return null;
         }
         $this->logger = $logger;
     }
     return $this->logger;
 }
Exemplo n.º 7
0
 /**
  * @covers Monolog\Logger::setHandlers
  */
 public function testSetHandlers()
 {
     $logger = new Logger(__METHOD__);
     $handler1 = new TestHandler();
     $handler2 = new TestHandler();
     $logger->pushHandler($handler1);
     $logger->setHandlers(array($handler2));
     // handler1 has been removed
     $this->assertEquals(array($handler2), $logger->getHandlers());
     $logger->setHandlers(array("AMapKey" => $handler1, "Woop" => $handler2));
     // Keys have been scrubbed
     $this->assertEquals(array($handler1, $handler2), $logger->getHandlers());
 }
 /**
  * 
  *
  * @return \Monolog\HandlerInterface[] 
  * @static 
  */
 public static function getHandlers()
 {
     return \Monolog\Logger::getHandlers();
 }
 /**
  * DynamicLogger constructor.
  */
 public function __construct()
 {
     $this->logger = Log::getMonolog();
     $this->handlers = $this->logger->getHandlers();
 }
Exemplo n.º 10
0
 /**
  * Initialize logging.
  */
 protected function getLogger()
 {
     $logger = new Logger('currycms');
     foreach ($this['log'] as $log) {
         if (isset($log['enabled']) && !$log['enabled']) {
             continue;
         }
         $clazz = new \ReflectionClass($log['type']);
         $arguments = isset($log['arguments']) ? $log['arguments'] : array();
         $handler = $clazz->newInstanceArgs($arguments);
         if (isset($log['buffer']) && $log['buffer']) {
             $handler = new BufferHandler($handler);
         }
         if (isset($log['fingersCrossed']) && $log['fingersCrossed']) {
             $handler = new FingersCrossedHandler($handler);
         }
         $logger->pushHandler($handler);
     }
     if (!count($logger->getHandlers())) {
         $logger->pushHandler(new NullHandler());
     }
     if ($this['developmentMode']) {
         $logger->pushProcessor(new IntrospectionProcessor(Logger::WARNING));
     }
     return $logger;
 }
Exemplo n.º 11
0
 /**
  * @return \Monolog\Handler\HandlerInterface[]
  */
 public function getHandlers()
 {
     return parent::getHandlers();
 }