MonologFormatterLogglyFormatter

Encodes message information into JSON in a format compatible with Loggly.

Defined (1)

The class is defined in the following location(s).

/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php  
  1. class LogglyFormatter extends JsonFormatter 
  2. /** 
  3. * Overrides the default batch mode to new lines for compatibility with the 
  4. * Loggly bulk API. 
  5. * @param integer $batchMode 
  6. */ 
  7. public function __construct($batchMode = self::BATCH_MODE_NEWLINES, $appendNewline = false) 
  8. parent::__construct($batchMode, $appendNewline); 
  9.  
  10. /** 
  11. * Appends the 'timestamp' parameter for indexing by Loggly. 
  12. * @see https://www.loggly.com/docs/automated-parsing/#json 
  13. * @see \Monolog\Formatter\JsonFormatter::format() 
  14. */ 
  15. public function format(array $record) 
  16. if (isset($record["datetime"]) && ($record["datetime"] instanceof \DateTime)) { 
  17. $record["timestamp"] = $record["datetime"]->format("Y-m-d\TH:i:s.uO"); 
  18. // TODO 2.0 unset the 'datetime' parameter, retained for BC 
  19.  
  20. return parent::format($record);