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

LoggerTrait

Constants

private JSON_FLAGS

private STANDARD_LEVELS

Methods

__construct(Repository $config, OutputInterface|null $output = null)

No description

void
reloadConfiguration()

Reload the cached stdout logger configuration.

void
log(mixed $level, string|Stringable $message, array $context = [])

Log a message at the given level.

string
getLineMessage(string $message, string $level = LogLevel::INFO, array $tags = [])

Format a human-readable log line with timestamp, colored level tag and context tags.

string
getJsonMessage(string $message, string $level, array $tags, array $context)

Format a structured JSON log line for log aggregators.

string|null
encodeJson(array $entry)

Encode a structured log entry without allowing user serializers to escape.

string
interpolate(string $message, array $context)

Interpolate context values into a message.

mixed
normalizeContextValue(mixed $value)

Normalize a top-level context value for structured output.

string
stringify(mixed $value)

Convert a log value to a safe string representation.

string
stringifyStringable(Stringable $value)

Convert a stringable object without allowing its failure to mask a log entry.

string
escapeLineValue(string $value)

Escape dynamic text that Symfony Console would otherwise interpret as markup.

Details

at line 54
__construct(Repository $config, OutputInterface|null $output = null)

No description

Parameters

Repository $config
OutputInterface|null $output

at line 66
void reloadConfiguration()

Reload the cached stdout logger configuration.

Boot-only. The cached format and enabled levels affect every subsequent log entry in the worker.

Return Value

void

at line 95
void log(mixed $level, string|Stringable $message, array $context = [])

Log a message at the given level.

Parameters

mixed $level
string|Stringable $message
array $context

Return Value

void

at line 136
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.

Parameters

string $message
string $level
array $tags

Return Value

string

at line 158
protected string getJsonMessage(string $message, string $level, array $tags, array $context)

Format a structured JSON log line for log aggregators.

Parameters

string $message
string $level
array $tags
array $context

Return Value

string

at line 186
protected string|null encodeJson(array $entry)

Encode a structured log entry without allowing user serializers to escape.

Parameters

array $entry

Return Value

string|null

at line 200
protected string interpolate(string $message, array $context)

Interpolate context values into a message.

Parameters

string $message
array $context

Return Value

string

at line 214
protected mixed normalizeContextValue(mixed $value)

Normalize a top-level context value for structured output.

Parameters

mixed $value

Return Value

mixed

at line 228
protected string stringify(mixed $value)

Convert a log value to a safe string representation.

Parameters

mixed $value

Return Value

string

at line 247
protected string stringifyStringable(Stringable $value)

Convert a stringable object without allowing its failure to mask a log entry.

Parameters

Stringable $value

Return Value

string

at line 259
protected string escapeLineValue(string $value)

Escape dynamic text that Symfony Console would otherwise interpret as markup.

Parameters

string $value

Return Value

string