Logger
class Logger
Supports the ability to produce logging.
Constants
| EMERGENCY |
Constant for alert level emergency. |
| ALERT |
Constant for alert level alert. |
| CRITICAL |
Constant for alert level critical. |
| ERROR |
Constant for alert level error. |
| WARNING |
Constant for alert level warning. |
| NOTICE |
Constant for alert level notice. |
| INFO |
Constant for alert level info. |
| DEBUG |
Constant for alert level debug. |
| private LEVELS |
Associative array of levels mapped to integers based on severity. |
| private LOG_FILE_PATH |
Path to log files. |
Properties
| static private string | $logFile | Full path and name of current log file. |
Methods
Performs system logging if we cannot write to log file. We also dump the message to the console/view.
Packages together the actual formatted log message with
Initializes the log file based on the environment (CLI or Web).
Checks if log directory is writeable. If not writable we write message to PHP log file and dump message to console or view.
Checks if log file is writable. If not writable we write message to PHP log file and dump message to console or view.
Performs operations for adding content to log files.
Checks if log directory exists. If not, then we create it.
Checks if log file exists. If not, then we create it.
Logs to file based on level. If level is info the anything with a severity level greater or equal to is logged.
Tests if the PSR-3 logging level that is provided is valid
Internal function for writing to log after all checks have passed.
Details
at line 60
static private void
emergencyFallback(string $message)
Performs system logging if we cannot write to log file. We also dump the message to the console/view.
at line 73
static private string
generateLogMessage(string $level, string $message, string $file, int $line)
Packages together the actual formatted log message with
at line 87
static private void
init()
Initializes the log file based on the environment (CLI or Web).
at line 106
static private void
isLogDirWritable(string $logDir)
Checks if log directory is writeable. If not writable we write message to PHP log file and dump message to console or view.
at line 120
static private void
isLogFileWritable()
Checks if log file is writable. If not writable we write message to PHP log file and dump message to console or view.
at line 134
static void
log(string $message, string $level = self::INFO)
Performs operations for adding content to log files.
at line 156
static private void
logDirExists(string $logDir)
Checks if log directory exists. If not, then we create it.
at line 167
static private void
logFileExists()
Checks if log file exists. If not, then we create it.
at line 183
static bool
shouldLog(string $level)
Logs to file based on level. If level is info the anything with a severity level greater or equal to is logged.
at line 200
static bool
verifyLoggingLevel(string $level)
Tests if the PSR-3 logging level that is provided is valid
at line 218
static private void
writeToLog(string $message, string $level)
Internal function for writing to log after all checks have passed.