Exemplo n.º 1
0
 /**
  * 
  * @return \Psr\Log\LoggerInterface
  */
 public function getLogger()
 {
     if (is_null($this->logger)) {
         $this->logger = new \common_log_Logger2Psr(\common_Logger::singleton());
     }
     return $this->logger;
 }
Exemplo n.º 2
0
 public function analyseLogPerformance()
 {
     common_Logger::singleton()->enable();
     $start = microtime(true);
     for ($i = 0; $i < self::RUNS; $i++) {
         // nothing
     }
     $emptyTime = microtime(true) - $start;
     echo "Idle run: " . $emptyTime . "<br />";
     $start = microtime(true);
     for ($i = 0; $i < self::RUNS; $i++) {
         common_Logger::t('a trace test message');
     }
     $traceTime = microtime(true) - $start;
     echo "Trace run: " . $traceTime . "<br />";
     $start = microtime(true);
     for ($i = 0; $i < self::RUNS; $i++) {
         common_Logger::i('a info test message');
     }
     $infoTime = microtime(true) - $start;
     echo "Info run: " . $infoTime . "<br />";
     common_Logger::singleton()->restore();
     common_Logger::singleton()->disable();
     $start = microtime(true);
     for ($i = 0; $i < self::RUNS; $i++) {
         common_Logger::i('a disabled test message');
     }
     $disabledTime = microtime(true) - $start;
     echo "Disabled run: " . $disabledTime . "<br />";
     common_Logger::singleton()->restore();
     $start = microtime(true);
     sleep(1);
     $testwait = microtime(true) - $start;
     echo "Wait: " . $testwait . "<br />";
     echo "ok";
 }
 public function __construct($message = null, $code = 0, Exception $previous = null)
 {
     parent::__construct($message, $code);
     common_Logger::singleton()->handleException($this);
 }
 /**
  * register a custom Errorhandler
  */
 protected function registerErrorhandler()
 {
     // register the logger as erorhandler
     common_Logger::singleton()->register();
 }
Exemplo n.º 5
0
 public function __construct($serviceKey, $message = '')
 {
     parent::__construct('Service "' . $serviceKey . '" not found' . (empty($message) ? '' : ': ' . $message));
     $this->serviceKey = $serviceKey;
     \common_Logger::singleton()->handleException($this);
 }