This class contains the main functionalities for the logging in CONTENIDO.
Examples:
$writer = cLogWriter::factory("File", array('destination' => 'contenido.log')); $log = new cLog($writer);
$log->addPriority("CONTENIDO", 10); $log->log("Contenido Log Message.", "CONTENIDO"); $log->contenido("Same log entry in short notation."); $log->removePriority("CONTENIDO");
$log->emerg("System down.");
$log->log('Notice Log Message', cLog::NOTICE);
$log->buffer('Buffered Log Message', cLog::WARN); $log->commit();
__call(string $method, array $arguments) : void
string
Name of the method
array
Array with the method arguments
\cInvalidArgumentException |
if the given priority is not supported |
---|
__construct(mixed $writer)
The log format interface of cLog is capable of being extended by subclasses. See the note about the log shortcuts below.
Log shortcuts are placeholders which are replaced when a log entry is created. Placeholders start with a percentage sign (%) and contain one or more characters. Each placeholder is handled by an own function which decides what to do.
mixed
writer Writer object (any subclass of cLogWriter), or false if cLog should handle the writer creation
addPriority(string $name, int $value) : void
string
Name of the log priority
int
Index value of the log priority
\cInvalidArgumentException |
if the given name is empty, already exists or the value already exists |
---|
buffer(string $message, mixed $priority) : void
string
Message to buffer
mixed
Priority of the log entry (optional)
commit(boolean $revoke) : void
boolean
Flag, whether the buffer is cleared or not (optional, default: true)
log(string $message, mixed $priority) : void
string
Message to log
mixed
Priority of the log entry (optional)
removePriority(string $name) : void
Default properties can not be removed.
string
Name of the log priority to remove
\cInvalidArgumentException |
if the given name is empty, does not exist or is a default priority |
---|
revoke() : void
setShortcutHandler(string $shortcut, string $handler) : bool
Each shortcut handler receives an array with the message and the priority of the entry.
string
Shortcut name
string
Name of the function to call
\cInvalidArgumentException |
if the given shortcut is empty or already in use or if the handler is not callable |
---|
bool
True if setting was successfulsetWriter(\cLogWriter $writer) : void
shDate() : string
Returns the current date
string
The current dateshLevel($info) : string
Returns the canonical name of the priority. The canonical name is padded to 10 characters to achieve a better formatting.
string
The canonical log levelshMessage($info) : string
Returns the log message.
string
The log messageunsetShortcutHandler(string $shortcut) : boolean
string
Name of the shortcut
\cInvalidArgumentException |
if the given shortcut handler does not exist |
---|
boolean
$_buffer : array
$_defaultPriorities : array
$_priorities : array
$_shortcutHandlers : array
ALERT
CRIT
DEBUG
EMERG
ERR
INFO
NOTICE
WARN