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:
@@ -15,6 +15,8 @@ class SihnonFramework_Log {
|
||||
protected $plugins = array();
|
||||
|
||||
public function __construct(SihnonFramework_Config $config) {
|
||||
$log = SihnonFramework_Main::instance()->log();
|
||||
|
||||
// Get a list of the logging plugins to be used
|
||||
$plugins = $config->get('logging.plugins');
|
||||
|
||||
@@ -22,12 +24,16 @@ class SihnonFramework_Log {
|
||||
// Get a list of all the instances of this plugin to be used
|
||||
$instances = $config->get("logging.{$plugin}");
|
||||
foreach ($instances as $instance) {
|
||||
$this->plugins[$plugin][] = array(
|
||||
'name' => $instance,
|
||||
'backend' => Sihnon_Log_PluginFactory::create($config, $plugin, $instance),
|
||||
'severity' => $config->get("logging.{$plugin}.{$instance}.severity"),
|
||||
'category' => $config->get("logging.{$plugin}.{$instance}.category"),
|
||||
);
|
||||
try {
|
||||
$this->plugins[$plugin][] = array(
|
||||
'name' => $instance,
|
||||
'backend' => Sihnon_Log_PluginFactory::create($config, $plugin, $instance),
|
||||
'severity' => $config->get("logging.{$plugin}.{$instance}.severity"),
|
||||
'category' => $config->get("logging.{$plugin}.{$instance}.category"),
|
||||
);
|
||||
} catch(SihnonFramework_Exception_LogException $e) {
|
||||
SihnonFramework_LogEntry::warning($log, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user