StdoutLogger
class StdoutLogger implements StdoutLoggerInterface
Low-level PSR-3 logger that writes directly to stdout.
Used by Swoole server infrastructure that needs logging before the application log stack is available. Supports human-readable line and structured JSON output.
Traits
Constants
| private JSON_FLAGS |
|
| private STANDARD_LEVELS |
|
Methods
Create a new stdout logger instance.
Reload the cached stdout logger configuration.
Log a message at the given level.
Format a human-readable log line with timestamp, colored level tag and context tags.
Format a structured JSON log line for log aggregators.
Encode a structured log entry without allowing user serializers to escape.
Interpolate context values into a message.
Normalize a top-level context value for structured output.
Convert a log value to a safe string representation.
Convert a stringable object without allowing its failure to mask a log entry.
Escape dynamic text that Symfony Console would otherwise interpret as markup.
Details
at line 59
__construct(Repository $config, OutputInterface|null $output = null)
Create a new stdout logger instance.
at line 71
void
reloadConfiguration()
Reload the cached stdout logger configuration.
The cached format and enabled levels affect every subsequent log entry in the worker.
at line 101
void
log(mixed $level, string|Stringable $message, array $context = [])
Log a message at the given level.
at line 142
protected string
getLineMessage(string $message, string $level = LogLevel::INFO, array $tags = [])
Format a human-readable log line with timestamp, colored level tag and context tags.
at line 164
protected string
getJsonMessage(string $message, string $level, array $tags, array $context)
Format a structured JSON log line for log aggregators.
at line 192
protected string|null
encodeJson(array $entry)
Encode a structured log entry without allowing user serializers to escape.
at line 210
protected string
interpolate(string $message, array $context)
Interpolate context values into a message.
at line 224
protected mixed
normalizeContextValue(mixed $value)
Normalize a top-level context value for structured output.
at line 238
protected string
stringify(mixed $value)
Convert a log value to a safe string representation.
at line 257
protected string
stringifyStringable(Stringable $value)
Convert a stringable object without allowing its failure to mask a log entry.
at line 273
protected string
escapeLineValue(string $value)
Escape dynamic text that Symfony Console would otherwise interpret as markup.