Bug fixes to reduce logging-related crashes

* Provide a method for plugins to report failure to initialise
* Check plugins initialised properly before adding to list of logging
backends
* Check the logger is available before trying to log a message
(might cause bugs if errors are logged very early in initialisation)
This commit is contained in:
2011-08-20 11:34:29 +01:00
parent fc33112097
commit 2781b63b68
4 changed files with 47 additions and 7 deletions

View File

@@ -125,13 +125,21 @@ class SihnonFramework_LogEntry {
}
protected static function log($logger, $severity, $message, $category = SihnonFramework_Log::CATEGORY_DEFAULT) {
if (!$logger) {
throw new SihnonFramework_Exception_InvalidLog();
}
$backtrace = debug_backtrace(false);
$entry = new static($severity, $category, time(), static::$localHostname, static::$localProgname, getmypid(), $backtrace[1]['file'], $backtrace[1]['line'], $message);
$logger->log($entry);
$logger->log($entry);
}
public static function logInternal($logger, $severity, $file, $line, $message, $category = SihnonFramework_Log::CATEGORY_DEFAULT) {
if (!$logger) {
throw new SihnonFramework_Exception_InvalidLog();
}
$entry = new static($severity, $category, time(), static::$localHostname, static::$localProgname, getmypid(), $file, $line, $message);
$logger->log($entry);
}