Beispiel #1
0
 /**
  * Logs a record by passing it to the registered handlers.
  * @param \CoreXEngine\Util\Logger\Log $log record to pass to the handlers
  * @return \CoreXEngine\Util\Logger\Logger
  */
 public function logRecord(Log $log)
 {
     foreach ($this->handler as $handler) {
         if ($handler->accepts($log->getLevel())) {
             $handler->handle($log);
         }
     }
     return $this;
 }
Beispiel #2
0
 /**
  * Handles the given error for the logger by printing it to stdout.
  * @param CoreXEngine\Util\Logger\Log $log record to handle
  * @return void
  */
 public function handle(Log $log)
 {
     print $log . ($this->showTrace ? $log->getStackTraceAsString() . PHP_EOL : '');
 }
Beispiel #3
0
 /**
  * Creates a new Log object with a given level and exception.
  * @param integer $level the log level wich indicated the severity.
  * @param \Exception $exception the exception we want to use for the log entry.
  * @return \CoreXEngine\Util\Logger\SimpleLog
  */
 public function __construct($level, \Exception $exception)
 {
     parent::__construct($level, null, $exception);
 }
Beispiel #4
0
 /**
  * Handles the given error by printing it as HTML.
  * @param CoreXEngine\Util\Logger\Log $log record to handle
  * @return void
  */
 public function handle(Log $log)
 {
     print '<div style="background-color:#fcc; border:1px solid #f00; padding: 4px;"><b>' . "{$log->getLevelAsString()}</b>: " . ($log->getMessage() ? $log->getMessage() . " " : "") . "<b>{$log->getExceptionName()}</b>: {$log->getException()->getMessage()} in <b>{$log->getFile()}</b>:{$log->getLine()}" . ($this->showTrace ? "<br /><pre>" . $log->getStackTraceAsString() . "</pre>" : '') . "</div><br /><br />" . PHP_EOL;
 }
Beispiel #5
0
 /**
  * Handles the given error for the logger by writing it to stderr.
  * @param CoreXEngine\Util\Logger\Log $log record to handle
  * @return void
  */
 public function handle(Log $log)
 {
     file_put_contents('php://stderr', (string) $log . ($this->showTrace ? $log->getStackTraceAsString() . PHP_EOL : ''));
 }