Class MOXMAN_Util_Logger

InheritanceMOXMAN_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

Hide inherited methods

MethodDescriptionDefined 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

Hide inherited constants

ConstantValueDescriptionDefined 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

__construct() public method

Constructs a new logger instance.

public void __construct ( $config = [] )
$config array

Name/value array with config settings.

debug() public method

Adds a debug message to the log file.

public void debug ( $msg )
$msg Mixed

One or more arguments to combine into a log message.

debugStackTrace() public method

Writes a stack trace to the debug log.

public void debugStackTrace ( )
error() public method

Adds a error message to the log file.

public void error ( $msg )
$msg Mixed

One or more arguments to combine into a log message.

fatal() public method

Adds a fatal message to the log file.

public void fatal ( $msg )
$msg Mixed

One or more arguments to combine into a log message.

getDateFormat() public method

Returns the current data format string.

public String getDateFormat ( )
return String

Current date format string.

getFileName() public method

Returns the current log file name or file name pattern.

public String getFileName ( )
return String

Current log file name or file name pattern.

getFilter() public method

Returns the current filter regexp.

public String getFilter ( )
return String

Filter regexp.

getFormat() public method

Returns the log message format.

public String getFormat ( )
return String

Log message format.

getLevel() public method

Returns the current log level for example LEVEL_DEBUG.

public int getLevel ( )
return int

Current log level for example LEVEL_DEBUG.

getMaxFiles() public method

Returns the current max files value.

public int getMaxFiles ( )
return int

Current max files value.

getMaxSize() public method

Returns the current max file size value.

public String getMaxSize ( )
return String

Current max size value.

getPath() public method

Returns the current log directory path.

public String getPath ( )
return String

Current log directory path.

info() public method

Adds a info message to the log file.

public void info ( $msg )
$msg Mixed

One or more arguments to combine into a log message.

isDebugEnabled() public method

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.

isErrorEnabled() public method

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.

isFatalEnabled() public method

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.

isInfoEnabled() public method

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.

isWarnEnabled() public method

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.

setDateFormat() public method

Sets the date format to put in the log files.

public void setDateFormat ( $format )
$format string

Data format string to use in log files.

setFileName() public method

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.

setFilter() public method

Sets the filter regexp.

public void setFilter ( $filter )
$filter string

Filter to apply.

setFormat() public method

Set log format the items are: {level}, {time} and {message}

public void setFormat ( $format )
$format string

Log message format string.

setLevel() public method

Sets the current log level, use the constants.

public void setLevel ( $level )
$level int

Log level instance for example DEBUG.

setMaxFiles() public method

Sets the number of files to roll before the last one gets deleted.

public void setMaxFiles ( $maxFiles )
$maxFiles int

Number of files to roll.

setMaxSize() public method

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.

setPath() public method

Sets the current log directory path.

public void setPath ( $path )
$path string

Path to directory to put the logs in.

warn() public method

Adds a warning message to the log file.

public void warn ( $msg )
$msg Mixed

One or more arguments to combine into a log message.