Encodes whatever record data is passed to it as json

This can be useful to log to databases or remote APIs

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'
public __construct(int $batchMode = 1, bool $appendNewline = true)
public format(array $record) : string

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

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::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
protected $appendNewline
protected $batchMode
protected Monolog\Formatter\NormalizerFormatter::$dateFormat
protected $includeStacktraces

  • var bool
protected Monolog\Formatter\NormalizerFormatter::$maxNormalizeDepth
protected Monolog\Formatter\NormalizerFormatter::$maxNormalizeItemCount
protected Monolog\Formatter\NormalizerFormatter::addJsonEncodeOption( $option)
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::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