示例#1
0
 /**
  * Format the log message. Prepends a DateTime formatted string and the
  * log level to the message.
  *
  * Example:
  *
  * $formatter = new BaseFormatter();
  * $formatter->format(LogLevel::WARNING, 'This is a warning');
  *
  * The above returns:
  *
  * 2015-08-19 14:31 +0300 WARNING This is a warning
  *
  * @param string $level the log level
  * @param string $message the log message
  * @return string the formatted message
  *
  * @see \Dialog\Formatter\FormatterInterface::format()
  */
 public function format($level, $message)
 {
     $date = $this->dateBuilder->buildFromTime();
     $level = strtoupper($level);
     $this->templateEngine->setTemplate('{date} {level} {message}');
     $this->templateEngine->setDelimiters('{', '}');
     return $this->templateEngine->render(compact('date', 'level', 'message'));
 }
示例#2
0
 /**
  * Gets the file path
  *
  * @return string the file path (path set + file name built)
  */
 protected function getFilePath()
 {
     $dateFormatted = $this->dateBuilder->buildFromTime();
     $path = rtrim($this->path, '/');
     return "{$path}/{$dateFormatted}.log";
 }