Beispiel #1
0
 public function emergency($message, array $args = [], array $context = [])
 {
     if (count($args)) {
         $message = vsprintf($message, $args);
     }
     return parent::emergency($message, $context);
 }
Beispiel #2
0
 /**
  * Проверяет, что сервис был корректно сконфигурирован
  *
  * @throws ConfigurationErrorException
  */
 private function checkIsConfigured()
 {
     if (!$this->isConfigured()) {
         $message = sprintf(self::ERR__NOT_CONFIGURED, get_class($this));
         $this->logger->emergency($message);
         throw new ConfigurationErrorException($message);
     }
 }
Beispiel #3
0
 /**
  *
  */
 public function testPushErrors()
 {
     $redis = \Mockery::mock('Predis\\Client')->shouldReceive('publish')->times(8)->with('log', \Mockery::any())->mock();
     $monolog = new Logger('test');
     $monolog->pushHandler(new PublishHandler(new RedisPublisher($redis)));
     $monolog->debug('the message was: {message}', ['DEBUG!']);
     $monolog->info('the message was: {message}', ['INFO!']);
     $monolog->notice('the message was: {message}', ['NOTICE!']);
     $monolog->warning('the message was: {message}', ['WARNING!']);
     $monolog->error('the message was: {message}', ['ERROR!']);
     $monolog->critical('the message was: {message}', ['CRITICAL!']);
     $monolog->alert('the message was: {message}', ['ALERT!']);
     $monolog->emergency('the message was: {message}', ['EMERGENCY!']);
 }
 /**
  * {@inheritdoc}
  */
 public function write($exception, $logType)
 {
     foreach ($this->rules as $rule => $condition) {
         switch ($rule) {
             case '!instanceof':
                 if ($exception instanceof $condition) {
                     return;
                 }
                 break;
             case 'instanceof':
                 if (!$exception instanceof $condition) {
                     return;
                 }
                 break;
         }
     }
     $context = is_callable($this->context) ? call_user_func($this->context, $exception) : null;
     if ($context === null) {
         $context = array('file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => $exception->getTrace(), 'logType' => $logType);
     }
     $this->logger->emergency($exception->getMessage(), $context);
 }
Beispiel #5
0
 /**
  * Adds a log record at the EMERGENCY level.
  *
  * @param string $message The log message
  * @param array $context The log context
  * @return Boolean Whether the record has been processed
  * @static 
  */
 public static function emergency($message, $context = array())
 {
     return \Monolog\Logger::emergency($message, $context);
 }
Beispiel #6
0
 /**
  * System is unusable.
  *
  * @param string $message
  * @param array $context
  * @return null
  */
 public function emergency($message, array $context = array())
 {
     $this->logger->emergency($message, $context);
 }
 /**
  * System is unusable.
  *
  * @param string $message
  * @param array $params
  * @param array $context
  * @return null
  */
 public function emergency($message, array $params = array(), array $context = array())
 {
     $logMessage = $this->createMessage($message, $params);
     $this->logger->emergency($logMessage, $context);
 }
Beispiel #8
0
 /**
  * @inheritdoc
  * @return boolean Whether the record has been processed.
  */
 public function emergency($message, array $context = [])
 {
     return $this->_monolog->emergency($message, $context);
 }
Beispiel #9
0
} catch (Exception $e) {
    $logger->alert("Unable to connect to DynamoDB (and validate the table)", ['exception' => $e]);
    exit(1);
}
//------------------------------------
// Create the process handler
#TODO - This will become a config option so custom Handlers can be used.
$handler = new \DynamoQueue\Worker\Handler\Autoloader();
//------------------------------------
// Create the (a) Worker
$worker = new \DynamoQueue\Worker\Worker($queue, $handler, $logger);
//---
declare (ticks=1);
pcntl_signal(SIGTERM, array($worker, 'stop'));
pcntl_signal(SIGINT, array($worker, 'stop'));
pcntl_signal(SIGQUIT, array($worker, 'stop'));
//---
try {
    $logger->notice("Worker started");
    $okay = $worker->run();
} catch (Exception $e) {
    $logger->emergency("An unknown exception has caused the queue to terminate", ['exception' => $e]);
    exit(1);
}
//---
$logger->notice("Worker stopped");
if ($okay) {
    exit(0);
} else {
    exit(1);
}
 /**
  * {@inheritdoc}
  */
 public function write(\Exception $exception, $logType)
 {
     $this->logger->emergency($exception->getMessage(), array('exception' => $exception->getTrace(), 'logType' => $logType));
 }
Beispiel #11
0
 /**
  * @param string $message
  * @param array $context
  * @return bool
  */
 public function emergency($message, array $context = array())
 {
     return parent::emergency($message, $context);
 }
<?php

include 'basics.php';
use unreal4u\MonologHandler;
use unreal4u\TgLog;
use Monolog\Logger;
#$monologTgLogger = new MonologHandler(new TelegramLog(BOT_TOKEN), A_USER_CHAT_ID, Logger::DEBUG); // Sends from DEBUG+
$monologTgLogger = new MonologHandler(new TgLog(BOT_TOKEN), A_USER_CHAT_ID, Logger::ERROR);
// Sends ERROR+
//Create logger
$logger = new Logger('TelegramLogger');
$logger->pushHandler($monologTgLogger);
//Now you can use the logger, and further attach additional information
$logger->debug('Nobody gives a dime for debug messages', ['moreInfo' => 'Within here']);
$logger->info('A user has logged in');
$logger->notice('Something unusual has happened!', ['it did indeed']);
$logger->warning('Somebody should attend this', ['some', 'extra' => 'information']);
$logger->error('Something really bad happened');
$logger->critical('A critical message', ['please' => 'Check this out']);
$logger->alert('This is an alert', ['oh no...' => 'This might be urgent']);
$logger->emergency('Run for your lives!', ['this is it' => 'everything has stopped working']);