Public Member Functions | |
| vdebug ($message) | |
| Log a message with debug-level priority. | |
| debug ($message) | |
| Log a message with debug-level priority. | |
| info ($message) | |
| Log a message with info-level priority. | |
| warning ($message) | |
| Log a message with warning-level priority. | |
| error ($message) | |
| Log a message with error-level priority. | |
| critical ($message) | |
| Log a message with error-level priority. | |
| logMessage ($priority, $message) | |
| Log a message with arbitrary priority. | |
| addRule (spunQ_LoggerRule $rule) | |
| Adds a rule to the logger. | |
| removeRule (spunQ_LoggerRule $rule) | |
| Removes a rule from the logger. | |
| clearAllRules () | |
| Removes all previously defined rules. | |
Static Public Member Functions | |
| static | getInstance () |
| Retrieves Singleton instance. | |
Public Attributes | |
| const | VERBOSE_DEBUG = 0 |
| The lowest possible log-level. | |
| const | VDEBUG = 0 |
| Alias for VERBOSE_DEBUG. | |
| const | DEBUG = 10 |
| Informative level for developers. | |
| const | INFO = 20 |
| Informative level for users. | |
| const | WARNING = 30 |
| Level for recoverable errors. | |
| const | ERROR = 40 |
| Level for unrecoverable errors. | |
| const | CRITICAL = 50 |
| Level for errors that require immediate attention. | |
| const | MAX_STACK_SIZE = 10 |
| Maximum number of log messages that shall be in queue. | |
Protected Member Functions | |
| __construct () | |
| Constructor. | |
Protected Attributes | |
| $messageStack = 0 | |
| Amount of messages that are in queue to be logged. | |
Private Member Functions | |
| fileToPath ($file, $function=NULL) | |
| Constructs a path definition out of a file-system path. | |
| formatFileToPath ($folder, $file) | |
| Formats the file between the folder and the file in spunQ's format. | |
| setLowestPriority () | |
| Sets the class variable lowestPriorityRule. | |
| getCaller () | |
| Uses spunQ_Backtrace to find calling function. | |
| getLoggingRules ($path, $priority) | |
| Finds the matching rule for the given caller and the given priority. | |
Private Attributes | |
| $rules = array() | |
| Rules that have been defined. | |
| $lowestPriorityRule = 100 | |
| Required for speed optimization. | |
Static Private Attributes | |
| static | $instance = NULL |
| Singleton instance. | |
To be able to log messages, the logger needs to know what to log and how to log it. The logger provides the possibility of defining rules that describe the condition to log and of having a LogTarget, which will take care of the actual logging. Rules can be added and removed. A rule consists of three components: A path, a level and a LogTarget.
Path: The term path describes the source of a logging event. This source is defined by the source file and line the event was triggered. For simplicity, it makes use of the module aliases in spunQ. This file, for example, is in the spunQ folder in core/logger/Logger.class.php. The corresponding path would be 'spunQ.logger.Logger'. Note that the extensions of the file are dropped for readability.Level: Log events can have several levels, reaching from verbose debug to critical. Although this is actually a numeric value, it is good practice to stick to the log level constants defined in this class. A rule will match any log event with equal or higher priority, which means That a rule for VDEBUG events will match any level (since VDEBUG has the least priority).LogTarget: The spunQ_ILogTarget that will receive the logging event for further processing, if the path and the priority of a triggered log event match the rule.Definition at line 169 of file Logger.class.php.
| spunQ_Logger::addRule | ( | spunQ_LoggerRule $ | rule | ) |
Adds a rule to the logger.
The rule consists of a path, a priority and a logTarget. The logTarget is used for logging events in the specified path with at least the specified priority.
| $rule | The rule to be added |
Definition at line 389 of file Logger.class.php.
| spunQ_Logger::clearAllRules | ( | ) |
Removes all previously defined rules.
Mainly required for testing.
Definition at line 481 of file Logger.class.php.
| spunQ_Logger::critical | ( | $ | message | ) |
Log a message with error-level priority.
| $message | An arbitrary message - could be an object, too |
Definition at line 312 of file Logger.class.php.
| spunQ_Logger::debug | ( | $ | message | ) |
Log a message with debug-level priority.
| $message | An arbitrary message - could be an object, too |
Definition at line 276 of file Logger.class.php.
| spunQ_Logger::error | ( | $ | message | ) |
Log a message with error-level priority.
| $message | An arbitrary message - could be an object, too |
Definition at line 303 of file Logger.class.php.
| spunQ_Logger::fileToPath | ( | $ | file, | |
| $ | function = NULL | |||
| ) | [private] |
Constructs a path definition out of a file-system path.
Folders defined as source folders will be used for the conversion.
| $file | An absolute file-system path to a file. | |
| $function | The name of a function to be appended. |
Definition at line 353 of file Logger.class.php.
| spunQ_Logger::formatFileToPath | ( | $ | folder, | |
| $ | file | |||
| ) | [private] |
Formats the file between the folder and the file in spunQ's format.
| $file | An absolute file-system path to a file. |
Definition at line 373 of file Logger.class.php.
| spunQ_Logger::getCaller | ( | ) | [private] |
Uses spunQ_Backtrace to find calling function.
All internal functions of the spunQ_Logger are skipped, of course.
Definition at line 442 of file Logger.class.php.
| static spunQ_Logger::getInstance | ( | ) | [static] |
| spunQ_Logger::getLoggingRules | ( | $ | path, | |
| $ | priority | |||
| ) | [private] |
Finds the matching rule for the given caller and the given priority.
| $path | The path of the event. | |
| $priority | The priority with which the Logger was invoked. |
Definition at line 464 of file Logger.class.php.
| spunQ_Logger::info | ( | $ | message | ) |
Log a message with info-level priority.
| $message | An arbitrary message - could be an object, too |
Definition at line 285 of file Logger.class.php.
| spunQ_Logger::logMessage | ( | $ | priority, | |
| $ | message | |||
| ) |
Log a message with arbitrary priority.
| $priority | A priority level | |
| $message | An arbitrary message - could be an object, too. LogTargets can make use of spunQ_LogTarget::convertObjectToString() in that case. |
Definition at line 323 of file Logger.class.php.
| spunQ_Logger::removeRule | ( | spunQ_LoggerRule $ | rule | ) |
Removes a rule from the logger.
| $rule | The rule to be removed |
Definition at line 404 of file Logger.class.php.
| spunQ_Logger::setLowestPriority | ( | ) | [private] |
Sets the class variable lowestPriorityRule.
Definition at line 417 of file Logger.class.php.
| spunQ_Logger::vdebug | ( | $ | message | ) |
Log a message with debug-level priority.
| $message | An arbitrary message - could be an object, too |
Definition at line 267 of file Logger.class.php.
| spunQ_Logger::warning | ( | $ | message | ) |
Log a message with warning-level priority.
| $message | An arbitrary message - could be an object, too |
Definition at line 294 of file Logger.class.php.
spunQ_Logger::$instance = NULL [static, private] |
spunQ_Logger::$lowestPriorityRule = 100 [private] |
Required for speed optimization.
The priority of the lowest priority rule is stored here, so the logger can decide very early whether a log event has the possibility of being processed.
Definition at line 241 of file Logger.class.php.
spunQ_Logger::$messageStack = 0 [protected] |
Amount of messages that are in queue to be logged.
A LogTarget might want to log something, in which case the logger will be re-activated, which might cause an infinite loop. This value gets incremented before a logged message is sent to its designated LogTargets and decremented afterwards to detect such cases.
Once MAX_STACK_SIZE is reached, no further log messages will be accepted - they are discarded silently.
Definition at line 253 of file Logger.class.php.
| const spunQ_Logger::MAX_STACK_SIZE = 10 |
Maximum number of log messages that shall be in queue.
Definition at line 210 of file Logger.class.php.
1.5.9