LineFormatter
extends NormalizerFormatter
in package
Formats incoming records into a one-line string
This is especially useful for logging to files
Tags
Table of Contents
Constants
- SIMPLE_DATE = "Y-m-d\\TH:i:sP"
- SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"
Properties
- $allowInlineLineBreaks : bool
- $dateFormat : string
- $format : string
- $ignoreEmptyContextAndExtra : bool
- $includeStacktraces : bool
- $maxNormalizeDepth : int
- $maxNormalizeItemCount : int
- $stacktracesParser : callable|null
- $jsonEncodeOptions : int
Methods
- __construct() : mixed
- addJsonEncodeOption() : self
- allowInlineLineBreaks() : self
- format() : mixed
- Formats a log record.
- formatBatch() : mixed
- Formats a set of log records.
- getDateFormat() : string
- getMaxNormalizeDepth() : int
- The maximum number of normalization levels to go through
- getMaxNormalizeItemCount() : int
- The maximum number of items to normalize per level
- ignoreEmptyContextAndExtra() : self
- includeStacktraces() : self
- removeJsonEncodeOption() : self
- setDateFormat() : self
- setJsonPrettyPrint() : self
- Enables `json_encode` pretty print.
- setMaxNormalizeDepth() : self
- setMaxNormalizeItemCount() : self
- stringify() : string
- convertToString() : string
- formatDate() : string
- normalize() : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
- normalizeException() : array<string|int, mixed>
- replaceNewlines() : string
- toJson() : string
- Return the JSON representation of a value
- formatException() : string
- stacktracesParser() : string
- stacktracesParserCustom() : string
Constants
SIMPLE_DATE
public
mixed
SIMPLE_DATE
= "Y-m-d\\TH:i:sP"
SIMPLE_FORMAT
public
mixed
SIMPLE_FORMAT
= "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"
Properties
$allowInlineLineBreaks
protected
bool
$allowInlineLineBreaks
$dateFormat
protected
string
$dateFormat
$format
protected
string
$format
$ignoreEmptyContextAndExtra
protected
bool
$ignoreEmptyContextAndExtra
$includeStacktraces
protected
bool
$includeStacktraces
$maxNormalizeDepth
protected
int
$maxNormalizeDepth
= 9
$maxNormalizeItemCount
protected
int
$maxNormalizeItemCount
= 1000
$stacktracesParser
protected
callable|null
$stacktracesParser
$jsonEncodeOptions
private
int
$jsonEncodeOptions
= \Monolog\Utils::DEFAULT_JSON_FLAGS
Methods
__construct()
public
__construct([string|null $format = null ][, string|null $dateFormat = null ][, bool $allowInlineLineBreaks = false ][, bool $ignoreEmptyContextAndExtra = false ][, bool $includeStacktraces = false ]) : mixed
Parameters
- $format : string|null = null
-
The format of the message
- $dateFormat : string|null = null
-
The format of the timestamp: one supported by DateTime::format
- $allowInlineLineBreaks : bool = false
-
Whether to allow inline line breaks in log entries
- $ignoreEmptyContextAndExtra : bool = false
- $includeStacktraces : bool = false
addJsonEncodeOption()
public
addJsonEncodeOption(int $option) : self
Parameters
- $option : int
Return values
selfallowInlineLineBreaks()
public
allowInlineLineBreaks([bool $allow = true ]) : self
Parameters
- $allow : bool = true
Return values
selfformat()
Formats a log record.
public
format(array<string|int, mixed> $record) : mixed
Parameters
- $record : array<string|int, mixed>
Return values
mixed —The formatted record
formatBatch()
Formats a set of log records.
public
formatBatch(array<string|int, mixed> $records) : mixed
Parameters
- $records : array<string|int, mixed>
-
A set of records to format
Return values
mixed —The formatted set of records
getDateFormat()
public
getDateFormat() : string
Return values
stringgetMaxNormalizeDepth()
The maximum number of normalization levels to go through
public
getMaxNormalizeDepth() : int
Return values
intgetMaxNormalizeItemCount()
The maximum number of items to normalize per level
public
getMaxNormalizeItemCount() : int
Return values
intignoreEmptyContextAndExtra()
public
ignoreEmptyContextAndExtra([bool $ignore = true ]) : self
Parameters
- $ignore : bool = true
Return values
selfincludeStacktraces()
public
includeStacktraces([bool $include = true ][, callable|null $parser = null ]) : self
Parameters
- $include : bool = true
- $parser : callable|null = null
Return values
selfremoveJsonEncodeOption()
public
removeJsonEncodeOption(int $option) : self
Parameters
- $option : int
Return values
selfsetDateFormat()
public
setDateFormat(string $dateFormat) : self
Parameters
- $dateFormat : string
Return values
selfsetJsonPrettyPrint()
Enables `json_encode` pretty print.
public
setJsonPrettyPrint(bool $enable) : self
Parameters
- $enable : bool
Return values
selfsetMaxNormalizeDepth()
public
setMaxNormalizeDepth(int $maxNormalizeDepth) : self
Parameters
- $maxNormalizeDepth : int
Return values
selfsetMaxNormalizeItemCount()
public
setMaxNormalizeItemCount(int $maxNormalizeItemCount) : self
Parameters
- $maxNormalizeItemCount : int
Return values
selfstringify()
public
stringify(mixed $value) : string
Parameters
- $value : mixed
Return values
stringconvertToString()
protected
convertToString(mixed $data) : string
Parameters
- $data : mixed
Return values
stringformatDate()
protected
formatDate(DateTimeInterface $date) : string
Parameters
- $date : DateTimeInterface
Return values
stringnormalize()
protected
normalize(mixed $data[, int $depth = 0 ]) : null|scalar|array<string|int, array<string|int, mixed>|scalar|null>
Parameters
- $data : mixed
- $depth : int = 0
Return values
null|scalar|array<string|int, array<string|int, mixed>|scalar|null>normalizeException()
protected
normalizeException(Throwable $e[, int $depth = 0 ]) : array<string|int, mixed>
Parameters
- $e : Throwable
- $depth : int = 0
Return values
array<string|int, mixed>replaceNewlines()
protected
replaceNewlines(string $str) : string
Parameters
- $str : string
Return values
stringtoJson()
Return the JSON representation of a value
protected
toJson(mixed $data[, bool $ignoreErrors = false ]) : string
Parameters
- $data : mixed
- $ignoreErrors : bool = false
Tags
Return values
string —if encoding fails and ignoreErrors is true 'null' is returned
formatException()
private
formatException(Throwable $e) : string
Parameters
- $e : Throwable
Return values
stringstacktracesParser()
private
stacktracesParser(Throwable $e) : string
Parameters
- $e : Throwable
Return values
stringstacktracesParserCustom()
private
stacktracesParserCustom(string $trace) : string
Parameters
- $trace : string