JsonFileBackend
class JsonFileBackend extends FileBackend (View source)
A log backend which writes log entries into a file in an easy to parse json format
Properties
protected int | $severityThreshold | One of the LOG_* constants. Anything below that will be filtered out. |
from AbstractBackend |
protected bool | $logIpAddress | Flag telling if the IP address of the current client (if available) should be logged. |
from AbstractBackend |
protected array | $severityLabels | An array of severity labels, indexed by their integer constant |
from FileBackend |
protected string | $logFileUrl | from FileBackend | |
protected int | $maximumLogFileSize | from FileBackend | |
protected int | $logFilesToKeep | from FileBackend | |
protected bool | $createParentDirectories | from FileBackend | |
protected bool | $logMessageOrigin | from FileBackend | |
protected resource|false | $fileHandle | from FileBackend |
Methods
The maximum severity to log, anything less severe will not be logged.
Enables or disables logging of IP addresses.
Sets URL pointing to the log file. Usually the full directory and the filename, however any valid stream URL is possible.
Sets the flag telling if parent directories in the path leading to the log file URL should be created if they don't exist.
Sets the maximum log file size, if the logfile is bigger, a new one is started.
If a new log file is started, keep this number of old log files.
If enabled, a hint about where the log message was created is added to the log file.
Carries out all actions necessary to prepare the logging backend, such as opening the log file or opening a database connection.
Rotate the log file and make sure the configured number of files is kept.
No description
Carries out all actions necessary to cleanly close the logging backend, such as closing the log file or disconnecting from a database.
Details
__construct(mixed $options = [])
Constructs this log backend
void
setSeverityThreshold(int $severityThreshold)
The maximum severity to log, anything less severe will not be logged.
void
setLogIpAddress(bool $logIpAddress)
Enables or disables logging of IP addresses.
void
setLogFileURL(string $logFileUrl)
Sets URL pointing to the log file. Usually the full directory and the filename, however any valid stream URL is possible.
void
setCreateParentDirectories(bool $flag)
Sets the flag telling if parent directories in the path leading to the log file URL should be created if they don't exist.
The default is to not create parent directories automatically.
void
setMaximumLogFileSize(int $maximumLogFileSize)
Sets the maximum log file size, if the logfile is bigger, a new one is started.
void
setLogFilesToKeep(int $logFilesToKeep)
If a new log file is started, keep this number of old log files.
void
setLogMessageOrigin(bool $flag)
If enabled, a hint about where the log message was created is added to the log file.
void
open()
Carries out all actions necessary to prepare the logging backend, such as opening the log file or opening a database connection.
protected void
rotateLogFile()
Rotate the log file and make sure the configured number of files is kept.
void
append(string $message, int $severity = LOG_INFO, mixed $additionalData = null, string $packageKey = null, string $className = null, string $methodName = null)
No description
void
close()
Carries out all actions necessary to cleanly close the logging backend, such as closing the log file or disconnecting from a database.
Note: for this backend we do nothing here and rely on PHP to close the filehandle when the request ends. This is to allow full logging until request end.