\AlphredLog

Simple static logging functionality that writes to files or STDERR

Summary

Methods
Properties
Constants
file()
console()
log()
$log_levels
No constants found
No protected methods found
No protected properties found
N/A
get_log_filename()
create_log_directory()
check_log()
rotate_log()
normalize_log_level()
trace()
is_loggable()
get_threshold()
date_console()
date_file()
No private properties found
N/A

Properties

$log_levels

$log_levels : array

An array that contans the valid log levels

Type

array

Methods

file()

file(string  $message, integer|string  $level = 1, string  $filename = 'workflow', boolean|integer  $trace = false) 

Log a message to a file

Parameters

string $message

the message to log

integer|string $level

the log level

string $filename

the filename of the log without an extension

boolean|integer $trace

how far back to trace

console()

console(string  $message, string|integer  $level = 1, boolean|integer  $trace = false) 

Log a message to the console (STDERR)

Parameters

string $message

the message to log

string|integer $level

the log level

boolean|integer $trace

how far back to trace

log()

log(string  $message, integer|string  $level = 1, string  $filename = 'workflow', boolean|integer  $trace = false) 

Log a message to both a file and the console

Parameters

string $message

the message to log

integer|string $level

the log level

string $filename

the filename of the log without an extension

boolean|integer $trace

how far back to trace

get_log_filename()

get_log_filename(string  $filename) : string

Gets the full filepath to the log file

Parameters

string $filename

a filename for a log file

Returns

string —

the full filepath for a log file

create_log_directory()

create_log_directory() 

Creates the workflow's data directory if it does not exist.

check_log()

check_log(  $filename) 

Checks to see if the log needs to be rotated

Parameters

$filename

rotate_log()

rotate_log(  $filename) 

Rotates the log

Parameters

$filename

normalize_log_level()

normalize_log_level(integer|string  $level) : string

Normalizes the log level, returning 'INFO' or 1 if invalid

Parameters

integer|string $level

the level represented as either a string or an integer

Returns

string —

the name of the log level

trace()

trace(boolean|integer  $depth = false) : string

Fetches information from a stack trace

Parameters

boolean|integer $depth

How far to do the trace, default is the last

Returns

string —

the file and line number of the trace

is_loggable()

is_loggable(mixed  $level) : boolean

Checks if a log level is within a display threshold

Parameters

mixed $level

Either a string or a

Returns

boolean —

Whether or not a value is above the logging threshold

get_threshold()

get_threshold() : integer

Gets the threshold for log messages

Returns

integer —

an integer matching a log level

date_console()

date_console() : string

Gets the time formatted for a console display log

Returns

string —

the time as HH:MM:SS

date_file()

date_file() : string

Gets a datestamp formatted for a file log

Returns

string —

Formatted as YYYY-MM-DD HH:MM:SS