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
stringName of the method
arrayArray 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.
mixedwriter Writer object (any subclass of cLogWriter), or false if cLog should handle the writer creation
addPriority(string $name, int $value) : void
stringName of the log priority
intIndex 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
stringMessage to buffer
mixedPriority of the log entry (optional)
commit(boolean $revoke) : void
booleanFlag, whether the buffer is cleared or not (optional, default: true)
log(string $message, mixed $priority) : void
stringMessage to log
mixedPriority of the log entry (optional)
removePriority(string $name) : void
Default properties can not be removed.
stringName 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.
stringShortcut name
stringName of the function to call
\cInvalidArgumentException |
if the given shortcut is empty or already in use or if the handler is not callable |
|---|
boolTrue if setting was successfulsetWriter(\cLogWriter $writer) : void
shDate() : string
Returns the current date
stringThe current dateshLevel($info) : string
Returns the canonical name of the priority. The canonical name is padded to 10 characters to achieve a better formatting.
stringThe canonical log levelshMessage($info) : string
Returns the log message.
stringThe log messageunsetShortcutHandler(string $shortcut) : boolean
stringName 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