ConsoleFormatter
in package
implements
FormatterInterface
Formats incoming records for console output by coloring them depending on log level.
Tags
Table of Contents
Interfaces
- FormatterInterface
- Interface for formatters
Constants
- SIMPLE_DATE = 'H:i:s'
- SIMPLE_FORMAT = "%datetime% %start_tag%%level_name%%end_tag% <comment>[%channel%]</> %message%%context%%extra%\n"
- LEVEL_COLOR_MAP = [\Monolog\Logger::DEBUG => 'fg=white', \Monolog\Logger::INFO => 'fg=green', \Monolog\Logger::NOTICE => 'fg=blue', \Monolog\Logger::WARNING => 'fg=cyan', \Monolog\Logger::ERROR => 'fg=yellow', \Monolog\Logger::CRITICAL => 'fg=red', \Monolog\Logger::ALERT => 'fg=red', \Monolog\Logger::EMERGENCY => 'fg=white;bg=red']
Properties
- $cloner : mixed
- $dumper : mixed
- $options : array<string|int, mixed>
- $outputBuffer : resource|null
Methods
- __construct() : mixed
- Available options: * format: The format of the outputted log string. The following placeholders are supported: %datetime%, %start_tag%, %level_name%, %end_tag%, %channel%, %message%, %context%, %extra%; * date_format: The format of the outputted date string; * colors: If true, the log string contains ANSI code to add color; * multiline: If false, "context" and "extra" are dumped on one line.
- format() : mixed
- Formats a log record.
- formatBatch() : mixed
- Formats a set of log records.
- dumpData() : string
- replacePlaceHolder() : array<string|int, mixed>
Constants
SIMPLE_DATE
public
mixed
SIMPLE_DATE
= 'H:i:s'
SIMPLE_FORMAT
public
mixed
SIMPLE_FORMAT
= "%datetime% %start_tag%%level_name%%end_tag% <comment>[%channel%]</> %message%%context%%extra%\n"
LEVEL_COLOR_MAP
private
mixed
LEVEL_COLOR_MAP
= [\Monolog\Logger::DEBUG => 'fg=white', \Monolog\Logger::INFO => 'fg=green', \Monolog\Logger::NOTICE => 'fg=blue', \Monolog\Logger::WARNING => 'fg=cyan', \Monolog\Logger::ERROR => 'fg=yellow', \Monolog\Logger::CRITICAL => 'fg=red', \Monolog\Logger::ALERT => 'fg=red', \Monolog\Logger::EMERGENCY => 'fg=white;bg=red']
Properties
$cloner
private
mixed
$cloner
$dumper
private
mixed
$dumper
$options
private
array<string|int, mixed>
$options
$outputBuffer
private
resource|null
$outputBuffer
Methods
__construct()
Available options: * format: The format of the outputted log string. The following placeholders are supported: %datetime%, %start_tag%, %level_name%, %end_tag%, %channel%, %message%, %context%, %extra%; * date_format: The format of the outputted date string; * colors: If true, the log string contains ANSI code to add color; * multiline: If false, "context" and "extra" are dumped on one line.
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $options : array<string|int, mixed> = []
format()
Formats a log record.
public
format(array<string|int, mixed> $record) : mixed
Parameters
- $record : array<string|int, mixed>
-
A record to format
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
dumpData()
private
dumpData(mixed $data[, bool $colors = null ]) : string
Parameters
- $data : mixed
- $colors : bool = null
Return values
stringreplacePlaceHolder()
private
replacePlaceHolder(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>