Log is the logic object Fusion uses to write runtime events to different channels,
each represented by a serializer in the serializers wrapper:
{
"log": {
"serializers": {
"<serializer-id>": "<serializer>"
}
}
}
[
"log" => [
"serializers" => [
"<serializer-id>" => "<serializer>"
]
]
]
The identifiers (<serializer-id>) are simple keys without any additional
functionality and map to serializers described in the following sections.
Note
If you include the following serializers in your configuration without custom
settings, you can use shorthand to map serializer identifiers (<serializer-id>)
directly to their classes, instead of specifying each serializer with a full
serializer entry.
Configurable Stream Serializers
The stream serializer formats log events and writes them to the standard
output stream. Fusion provides two prebuilt stream serializer implementations.
One for highlighted terminal output:
{
"serializer": "Valvoid\\Fusion\\Log\\Serializers\\Streams\\Terminal\\Terminal",
"threshold": "<level>"
}
[
"serializer" => \Valvoid\Fusion\Log\Serializers\Streams\Terminal\Terminal::class,
"threshold" => "<level>"
]
And one for parseable JSON output:
Valvoid\\Fusion\\Log\\Serializers\\Streams\\JSON\\JSON: JSON\Valvoid\Fusion\Log\Serializers\Streams\JSON\JSON::class: PHP
Threshold Level
By default, the threshold level is info. If the optional threshold entry is
set, the serializer will use that value. Regardless of the value, each event is
evaluated against all levels in a fixed top-down sequence:
debug,\Valvoid\Fusion\Log\Events\Level::DEBUGverbose,\Valvoid\Fusion\Log\Events\Level::VERBOSEinfo,\Valvoid\Fusion\Log\Events\Level::INFO: defaultnotice,\Valvoid\Fusion\Log\Events\Level::NOTICEwarning,\Valvoid\Fusion\Log\Events\Level::WARNINGerror,\Valvoid\Fusion\Log\Events\Level::ERROR
For example, with the default threshold info, events at info,
notice, warning, and error will be logged.
Configurable File Serializers
The file serializer formats log events and writes them to a file in the user's
state directory. Fusion provides two prebuilt file serializer implementations.
One for plain text output:
{
"serializer": "Valvoid\\Fusion\\Log\\Serializers\\Files\\Text\\Text",
"filename": "<format>",
"threshold": "<level>"
}
[
"serializer" => \Valvoid\Fusion\Log\Serializers\Files\Text\Text::class,
"filename" => "<format>",
"threshold" => "<level>"
]
And one for parseable JSON output:
Valvoid\\Fusion\\Log\\Serializers\\Files\\JSON\\JSON: JSON\Valvoid\Fusion\Log\Serializers\Files\JSON\JSON::class: PHP
Threshold Level
By default, the threshold level is warning. If the optional threshold entry is
set, the serializer will use that value. Regardless of the value, each event is
evaluated against all levels in a fixed top-down sequence:
debug,\Valvoid\Fusion\Log\Events\Level::DEBUGverbose,\Valvoid\Fusion\Log\Events\Level::VERBOSEinfo,\Valvoid\Fusion\Log\Events\Level::INFOnotice,\Valvoid\Fusion\Log\Events\Level::NOTICEwarning,\Valvoid\Fusion\Log\Events\Level::WARNING: defaulterror,\Valvoid\Fusion\Log\Events\Level::ERROR
For example, with the default value set to warning, events at the
warning and error levels will be logged.
Filename Format
By default, the filename format is Y.m.d. If the optional filename entry is
set to one of the following, the serializer will use that value:
Y.m: 2024.12Y.m.d: 2024.12.06Y.m.d_H:i: 2024.12.01_20:01Y.m.d_H: 2024.04.09_07Y: 2024
The format constants follow PHP's standard date function. Y for a four-digit
year, m for a two-digit month, d for a two-digit day, H for a two-digit
hour (24-hour format), and i for a two-digit minute. For more details, see
the official PHP documentation.