Esempio n. 1
0
 /**
  * Logs with an arbitrary level.
  *
  * Also adds few items to the context array.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     $context = array_merge(array('_name' => $this->name, '_channel' => $this->name, '_uuid' => $this->uuid, '_tags' => isset($context['_tags']) ? is_array($context['_tags']) ? $context['_tags'] : explode(',', trim((string) $context['_tags'])) : array(), '_level' => $level, '_timestamp' => Timer::getMicroTime(), '_date' => new \DateTime()), $context);
     $message = StringUtils::interpolate((string) $message, $context);
     foreach ($this->writers as $writer) {
         $writer->log($level, $message, $context);
     }
 }
Esempio n. 2
0
File: Logger.php Progetto: splot/log
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     if (!$this->isEnabled()) {
         return false;
     }
     $tags = array();
     if (isset($context['_tags'])) {
         $tags = is_array($context['_tags']) ? $context['_tags'] : explode(',', trim((string) $context['_tags']));
         unset($context['_tags']);
     }
     $timer = null;
     if (isset($context['_timer']) && $context['_timer'] instanceof Timer) {
         $timer = $context['_timer'];
         unset($context['_timer']);
     }
     $this->_log[] = array('message' => StringUtils::parseVariables((string) $message, $context), 'context' => $context, '_tags' => $tags, '_timestamp' => Timer::getMicroTime(), '_time' => new \DateTime(), '_level' => $level, '_timer' => $timer);
 }
Esempio n. 3
0
 public function testGetMicroTime()
 {
     $this->assertInternalType('float', Timer::getMicroTime());
     $now = time();
     $mtime = Timer::getMicroTime();
     $this->assertTrue($mtime > $now);
     $this->assertTrue($now + 1 > $mtime);
 }