Example #1
0
 /**
  * log
  *
  * @param string $level
  * @param string $message
  * @param array $context
  *
  * @throws LoggerException
  *
  * @return mixed
  */
 public function log($level, $message, array $context = [])
 {
     if (!in_array($this->mode, ['development', 'production'])) {
         throw new LoggerException($this->mode . ' n\'est pas définir');
     }
     if ($this->mode === 'development') {
         die(static::htmlFormat($level, $message, $context));
     }
     if ($this->mode === 'production') {
         if (!empty($context)) {
             $message = '\'' . $message . '\'' . ' in ' . $context['file'] . ' at ' . $context['line'];
             if (isset($context['trace'])) {
                 if (is_string($context['trace'])) {
                     $message .= $context['trace'];
                 }
             }
         }
         Storage::append($this->path, static::textFormat($level, $message . '\\n'));
     }
     return $this;
 }
Example #2
0
 public function testAppend()
 {
     $this->assertEquals(4, Storage::append(dirname(__DIR__) . '/data/file.txt', 'data'));
 }