$options
$options : array
Log array options.
Class Logger.
This class is responsible for handling log operations, including writing log messages to files, managing log levels, formatting messages, and handling log contexts. It supports various log configurations such as log format, date format, log file path, and context management.
$options : array
Log array options.
__construct(string $logDirectory, string $logLevelThreshold = LogLevel::DEBUG, array$options = []) : void
Constructor.
Initializes the logger by setting up the log directory, log level, and file options.
string | $logDirectory | The directory where log files are stored. |
string | $logLevelThreshold | The log level threshold (default: LogLevel::DEBUG). |
array |
$options | Optional configurations for the logger. |
If the log file cannot be created or opened.
log(mixed $level, string|\Stringable $message, array$context = []) : void
Logs with an arbitrary level.
mixed | $level | Holds the log level. |
string|\Stringable | $message | Holds the log message. |
array |
$context | Holds the context of message. |
error(string|\Stringable $message, array$context = []) : void
Runtime errors that do not require immediate action but should typically be logged and monitored.
string|\Stringable | $message | Holds the message for runtime errors. |
array |
$context | Holds the context of message. |
formatMessage(string $level, string|\Stringable $message, array$context) : string
Formats a log message for writing to the file.
string | $level | The log level of the message. |
string|\Stringable | $message | The message to log. |
array |
$context | The context for the log message. |
The formatted message.