Class MOXMAN_Util_Logger
Inheritance | MOXMAN_Util_Logger |
---|
Logging utility class. This class handles basic logging with levels, log rotation and custom log formats. It's designed to be compact but still powerful and flexible.
Public Methods
Method | Description | Defined By |
---|---|---|
__construct() | Constructs a new logger instance. | MOXMAN_Util_Logger |
debug() | Adds a debug message to the log file. | MOXMAN_Util_Logger |
debugStackTrace() | Writes a stack trace to the debug log. | MOXMAN_Util_Logger |
error() | Adds a error message to the log file. | MOXMAN_Util_Logger |
fatal() | Adds a fatal message to the log file. | MOXMAN_Util_Logger |
getDateFormat() | Returns the current data format string. | MOXMAN_Util_Logger |
getFileName() | Returns the current log file name or file name pattern. | MOXMAN_Util_Logger |
getFilter() | Returns the current filter regexp. | MOXMAN_Util_Logger |
getFormat() | Returns the log message format. | MOXMAN_Util_Logger |
getLevel() | Returns the current log level for example LEVEL_DEBUG. | MOXMAN_Util_Logger |
getMaxFiles() | Returns the current max files value. | MOXMAN_Util_Logger |
getMaxSize() | Returns the current max file size value. | MOXMAN_Util_Logger |
getPath() | Returns the current log directory path. | MOXMAN_Util_Logger |
info() | Adds a info message to the log file. | MOXMAN_Util_Logger |
isDebugEnabled() | Returns true/false if the debug level is available. | MOXMAN_Util_Logger |
isErrorEnabled() | Returns true/false if the error level is available. | MOXMAN_Util_Logger |
isFatalEnabled() | Returns true/false if the fatal level is available. | MOXMAN_Util_Logger |
isInfoEnabled() | Returns true/false if the info level is available. | MOXMAN_Util_Logger |
isWarnEnabled() | Returns true/false if the warn level is available. | MOXMAN_Util_Logger |
setDateFormat() | Sets the date format to put in the log files. | MOXMAN_Util_Logger |
setFileName() | Sets the file name or file name pattern to use to save the log files. | MOXMAN_Util_Logger |
setFilter() | Sets the filter regexp. | MOXMAN_Util_Logger |
setFormat() | Set log format the items are: {level}, {time} and {message} | MOXMAN_Util_Logger |
setLevel() | Sets the current log level, use the constants. | MOXMAN_Util_Logger |
setMaxFiles() | Sets the number of files to roll before the last one gets deleted. | MOXMAN_Util_Logger |
setMaxSize() | Sets the max log file size. If the log file gets larger than this size it will be rolled. | MOXMAN_Util_Logger |
setPath() | Sets the current log directory path. | MOXMAN_Util_Logger |
warn() | Adds a warning message to the log file. | MOXMAN_Util_Logger |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
LEVEL_DEBUG | 0 | Debug level. | MOXMAN_Util_Logger |
LEVEL_ERROR | 30 | Error level. | MOXMAN_Util_Logger |
LEVEL_FATAL | 40 | Fatal level. | MOXMAN_Util_Logger |
LEVEL_INFO | 10 | Info level. | MOXMAN_Util_Logger |
LEVEL_WARN | 20 | Warning level. | MOXMAN_Util_Logger |
Method Details
Constructs a new logger instance.
public void __construct ( $config = [] ) | ||
$config | array | Name/value array with config settings. |
Adds a debug message to the log file.
public void debug ( $msg ) | ||
$msg | Mixed | One or more arguments to combine into a log message. |
Writes a stack trace to the debug log.
public void debugStackTrace ( ) |
Adds a error message to the log file.
public void error ( $msg ) | ||
$msg | Mixed | One or more arguments to combine into a log message. |
Adds a fatal message to the log file.
public void fatal ( $msg ) | ||
$msg | Mixed | One or more arguments to combine into a log message. |
Returns the current data format string.
public String getDateFormat ( ) | ||
return | String | Current date format string. |
---|
Returns the current log file name or file name pattern.
public String getFileName ( ) | ||
return | String | Current log file name or file name pattern. |
---|
Returns the current filter regexp.
public String getFilter ( ) | ||
return | String | Filter regexp. |
---|
Returns the log message format.
public String getFormat ( ) | ||
return | String | Log message format. |
---|
Returns the current log level for example LEVEL_DEBUG.
public int getLevel ( ) | ||
return | int | Current log level for example LEVEL_DEBUG. |
---|
Returns the current max files value.
public int getMaxFiles ( ) | ||
return | int | Current max files value. |
---|
Returns the current max file size value.
public String getMaxSize ( ) | ||
return | String | Current max size value. |
---|
Returns the current log directory path.
public String getPath ( ) | ||
return | String | Current log directory path. |
---|
Adds a info message to the log file.
public void info ( $msg ) | ||
$msg | Mixed | One or more arguments to combine into a log message. |
Returns true/false if the debug level is available.
public Boolean isDebugEnabled ( ) | ||
return | Boolean | True/false if the level is higher or equals to debug. |
---|
Returns true/false if the error level is available.
public Boolean isErrorEnabled ( ) | ||
return | Boolean | True/false if the level is higher or equals to error. |
---|
Returns true/false if the fatal level is available.
public Boolean isFatalEnabled ( ) | ||
return | Boolean | True/false if the level is higher or equals to fatal. |
---|
Returns true/false if the info level is available.
public Boolean isInfoEnabled ( ) | ||
return | Boolean | True/false if the level is higher or equals to info. |
---|
Returns true/false if the warn level is available.
public Boolean isWarnEnabled ( ) | ||
return | Boolean | True/false if the level is higher or equals to warn. |
---|
Sets the date format to put in the log files.
public void setDateFormat ( $format ) | ||
$format | string | Data format string to use in log files. |
Sets the file name or file name pattern to use to save the log files.
public void setFileName ( $fileName ) | ||
$fileName | string | File name or file name pattern to store the log data in. |
Sets the filter regexp.
public void setFilter ( $filter ) | ||
$filter | string | Filter to apply. |
Set log format the items are: {level}, {time} and {message}
public void setFormat ( $format ) | ||
$format | string | Log message format string. |
Sets the current log level, use the constants.
public void setLevel ( $level ) | ||
$level | int | Log level instance for example DEBUG. |
Sets the number of files to roll before the last one gets deleted.
public void setMaxFiles ( $maxFiles ) | ||
$maxFiles | int | Number of files to roll. |
Sets the max log file size. If the log file gets larger than this size it will be rolled.
public void setMaxSize ( $size ) | ||
$size | string | Size string to parse could be for example: 10mb, 10k or 10. |
Sets the current log directory path.
public void setPath ( $path ) | ||
$path | string | Path to directory to put the logs in. |
Adds a warning message to the log file.
public void warn ( $msg ) | ||
$msg | Mixed | One or more arguments to combine into a log message. |