JsonFormatter

Encodes whatever record data is passed to it as json This can be useful to log to databases or remote APIs
extends Monolog\Formatter\NormalizerFormatter

Known subclasses

SAREhub\Commons\Logger\DefaultJsonLogFormatter
Methods Summary
public
# __construct( int $batchMode = 1, bool $appendNewline = true )
public
# getBatchMode( )
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
# isAppendingNewlines( )
True if newlines are appended to every formatted record
public
# format( array $record )
public
# formatBatch( array $records )
public
# includeStacktraces( bool $include = true )
protected
# formatBatchJson( array $records )
Return a JSON-encoded array of records.
protected
# formatBatchNewlines( array $records )
Use new lines to separate records instead of a JSON-encoded array.
protected
# normalize( mixed $data )
protected
# normalizeException( \Exception|\Throwable $e )
Normalizes given exception with or without its own stack trace based on `includeStacktraces` property.

Overrides

Methods inherited from Monolog\Formatter\NormalizerFormatter
__construct(), format(), formatBatch(), normalize(), normalizeException(), toJson(), detectAndCleanUtf8()
Constants Summary
public int BATCH_MODE_JSON
# 1
public int BATCH_MODE_NEWLINES
# 2
Constants inherited from Monolog\Formatter\NormalizerFormatter
SIMPLE_DATE
Properties Summary
protected $batchMode

# NULL
protected $appendNewline

# NULL
protected bool $includeStacktraces

# false
Properties inherited from Monolog\Formatter\NormalizerFormatter
$dateFormat