Encodes whatever record data is passed to it as json

This can be useful to log to databases or remote APIs

CloneableInstantiable
ExtendsMonolog\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 __construct(int $batchMode = 1, bool $appendNewline = true, bool $ignoreEmptyContextAndExtra = false)
public Monolog\Formatter\NormalizerFormatter::addJsonEncodeOption( $option)
public format(array $record) : string
 

{@inheritdoc}

  • suppress PhanTypeComparisonToArray
public formatBatch(array $records) : string
 

{@inheritdoc}

public 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 includeStacktraces(bool $include = true)
public isAppendingNewlines() : bool
 

True if newlines are appended to every formatted record

public Monolog\Formatter\NormalizerFormatter::removeJsonEncodeOption( $option)
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
Properties
protected $appendNewline
protected $batchMode
protected Monolog\Formatter\NormalizerFormatter::$dateFormat
protected $ignoreEmptyContextAndExtra
protected $includeStacktraces
 
  • var bool
protected Monolog\Formatter\NormalizerFormatter::$maxNormalizeDepth
protected Monolog\Formatter\NormalizerFormatter::$maxNormalizeItemCount
Methods
protected formatBatchJson(array $records) : string
 

Return a JSON-encoded array of records.

protected formatBatchNewlines(array $records) : string
 

Use new lines to separate records instead of a
JSON-encoded array.

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

Normalizes given $data.

  • return mixed
protected 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::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