LoggerTrait
LoggerTrait class
Table of Contents
Properties
- $log_dir : string
- The directory where the log file will be created.
- $log_name : string
- The name of the log file to write to.
Methods
- log() : void
- Logs a message to a specified log file, creating the log directory if it does not exist.
- set_log_name() : void
- Sets the name of the log file to write to.
- get_log_file_path() : string
- Gets the full path to the log file.
Properties
$log_dir
The directory where the log file will be created.
protected
string
$log_dir
= BCM_UPLOADS_PATH
$log_name
The name of the log file to write to.
protected
string
$log_name
= 'default.log'
Methods
log()
Logs a message to a specified log file, creating the log directory if it does not exist.
public
log(string $message[, string $type = 'info' ][, string|null $log_name = null ]) : void
Parameters
- $message : string
-
The message to log.
- $type : string = 'info'
-
Optional. The type of log message. Default is 'info'.
- $log_name : string|null = null
-
Optional. The name of the log file to write to. If null, the default log file name is used.
set_log_name()
Sets the name of the log file to write to.
public
set_log_name(string $name) : void
Parameters
- $name : string
-
The name of the log file.
get_log_file_path()
Gets the full path to the log file.
protected
get_log_file_path(string $log_name) : string
Parameters
- $log_name : string
-
The log file name.
Return values
string —The full path to the log file.