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

CloneableInstantiable
ExtendsMonolog\Formatter\JsonFormatter
Monolog\Formatter\NormalizerFormatter
ImplementsMonolog\Formatter\FormatterInterface
Constants
public Monolog\Formatter\JsonFormatter::BATCH_MODE_JSON = 1
public Monolog\Formatter\JsonFormatter::BATCH_MODE_NEWLINES = 2
public Monolog\Formatter\NormalizerFormatter::SIMPLE_DATE = 'Y-m-d\TH:i:sP'
Methods
public Monolog\Formatter\JsonFormatter::__construct(int $batchMode = 1, bool $appendNewline = true)
public format(array $record) : string
 
Appends the 'hostname' and 'appname' parameter for indexing by Logmatic.

  • see http://doc.logmatic.io/docs/basics-to-send-data
  • see \Monolog\Formatter\JsonFormatter::format()
public Monolog\Formatter\JsonFormatter::formatBatch(array $records) : string
 
{@inheritdoc}

public Monolog\Formatter\JsonFormatter::getBatchMode() : int
 
The batch mode option configures the formatting style for multiple records. By default, multiple records will be formatted as a JSON-encoded array. However, for compatibility with some API endpoints, alternative styles are available.

public Monolog\Formatter\NormalizerFormatter::getMaxNormalizeDepth() : int
 
The maximum number of normalization levels to go through

public Monolog\Formatter\NormalizerFormatter::getMaxNormalizeItemCount() : int
 
The maximum number of items to normalize per level

public Monolog\Formatter\JsonFormatter::includeStacktraces(bool $include = true)
public Monolog\Formatter\JsonFormatter::isAppendingNewlines() : bool
 
True if newlines are appended to every formatted record

public setAppname(string $appname) : self
public setHostname(string $hostname) : self
public Monolog\Formatter\NormalizerFormatter::setJsonPrettyPrint(bool $enable) : self
 
Enables `json_encode` pretty print.

public Monolog\Formatter\NormalizerFormatter::setMaxNormalizeDepth(int $maxNormalizeDepth) : self
public Monolog\Formatter\NormalizerFormatter::setMaxNormalizeItemCount(int $maxNormalizeItemCount) : self
Constants
protected Monolog\Formatter\LogmaticFormatter::MARKERS = ['sourcecode', 'php']
Properties
protected Monolog\Formatter\JsonFormatter::$appendNewline
protected $appname
 


  • var string
protected Monolog\Formatter\JsonFormatter::$batchMode
protected Monolog\Formatter\NormalizerFormatter::$dateFormat
protected $hostname
 


  • var string
protected Monolog\Formatter\JsonFormatter::$includeStacktraces
 


  • var bool
protected Monolog\Formatter\NormalizerFormatter::$maxNormalizeDepth
protected Monolog\Formatter\NormalizerFormatter::$maxNormalizeItemCount
Methods
protected Monolog\Formatter\NormalizerFormatter::addJsonEncodeOption( $option)
protected Monolog\Formatter\JsonFormatter::formatBatchJson(array $records) : string
 
Return a JSON-encoded array of records.

protected Monolog\Formatter\JsonFormatter::formatBatchNewlines(array $records) : string
 
Use new lines to separate records instead of a JSON-encoded array.

protected Monolog\Formatter\NormalizerFormatter::formatDate(DateTimeInterface $date)
protected Monolog\Formatter\JsonFormatter::normalize( $data, int $depth = 0)
 
Normalizes given $data.

  • return mixed
protected Monolog\Formatter\JsonFormatter::normalizeException(Throwable $e, int $depth = 0) : array
 
Normalizes given exception with or without its own stack trace based on `includeStacktraces` property.

protected Monolog\Formatter\NormalizerFormatter::removeJsonEncodeOption( $option)
protected Monolog\Formatter\NormalizerFormatter::toJson( $data, bool $ignoreErrors = false) : string
 
Return the JSON representation of a value

  • throws RuntimeException if encoding fails and errors are not ignored
  • return string if encoding fails and ignoreErrors is true 'null' is returned
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only