Documentation

MongoDBFormatter
in package
implements FormatterInterface

Formats a record for use with the MongoDBHandler.

Tags
author

Florian Plattner me@florianplattner.de

Interfaces, Classes and Traits

FormatterInterface
Interface for formatters

Table of Contents

$exceptionTraceAsString  : bool
$isLegacyMongoExt  : bool
$maxNestingLevel  : int
__construct()  : mixed
format()  : array<string|int, mixed>
Formats a log record.
formatBatch()  : array<string|int, array<string|int, mixed>>
Formats a set of log records.
formatArray()  : array<string|int, mixed>|string
formatDate()  : UTCDateTime
formatException()  : array<string|int, mixed>|string
formatObject()  : array<string|int, mixed>|string
getMongoDbDateTime()  : UTCDateTime
legacyGetMongoDbDateTime()  : UTCDateTime
This is needed to support MongoDB Driver v1.19 and below

Properties

Methods

__construct()

public __construct([int $maxNestingLevel = 3 ][, bool $exceptionTraceAsString = true ]) : mixed
Parameters
$maxNestingLevel : int = 3

0 means infinite nesting, the $record itself is level 1, $record['context'] is 2

$exceptionTraceAsString : bool = true

set to false to log exception traces as a sub documents instead of strings

Return values
mixed

format()

Formats a log record.

public format(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
$record : array<string|int, mixed>

A record to format

Return values
array<string|int, mixed>

formatBatch()

Formats a set of log records.

public formatBatch(array<string|int, mixed> $records) : array<string|int, array<string|int, mixed>>
Parameters
$records : array<string|int, mixed>

A set of records to format

Return values
array<string|int, array<string|int, mixed>>

formatArray()

protected formatArray(array<string|int, mixed> $array, int $nestingLevel) : array<string|int, mixed>|string
Parameters
$array : array<string|int, mixed>
$nestingLevel : int
Return values
array<string|int, mixed>|string

Array except when max nesting level is reached then a string "[...]"

formatDate()

protected formatDate(DateTimeInterface $value, int $nestingLevel) : UTCDateTime
Parameters
$value : DateTimeInterface
$nestingLevel : int
Return values
UTCDateTime

formatException()

protected formatException(Throwable $exception, int $nestingLevel) : array<string|int, mixed>|string
Parameters
$exception : Throwable
$nestingLevel : int
Return values
array<string|int, mixed>|string

formatObject()

protected formatObject(mixed $value, int $nestingLevel) : array<string|int, mixed>|string
Parameters
$value : mixed
$nestingLevel : int
Return values
array<string|int, mixed>|string

getMongoDbDateTime()

private getMongoDbDateTime(DateTimeInterface $value) : UTCDateTime
Parameters
$value : DateTimeInterface
Return values
UTCDateTime

legacyGetMongoDbDateTime()

This is needed to support MongoDB Driver v1.19 and below

private legacyGetMongoDbDateTime(DateTimeInterface $value) : UTCDateTime

See https://github.com/mongodb/mongo-php-driver/issues/426

It can probably be removed in 2.1 or later once MongoDB's 1.2 is released and widely adopted

Parameters
$value : DateTimeInterface
Return values
UTCDateTime

Search results