Files
sihnon-php-lib/source/lib/SihnonFramework/Log.class.php
Ben Roberts 81521eae5f Updates framework to support automated framework subclasses
All framework classes have been renamed to use the SihnonFramework_ prefix.
The class autoloader now looks for subclasses of the framework classes in the Sihnon_Lib directory, and
automatically creates them if they don't exist. The autoloader correctly creates interfaces and abstract
classes as needed, by using reflection to check the type of the parent class.
All references to classes within the framework now use the Sihnon_ prefix.
The PluginFactory supports multiple scan directories, and will search both the framework and subclass class
tree to find candidate plugins.
2010-10-10 18:32:16 +01:00

55 lines
1.3 KiB
PHP

<?php
class SihnonFramework_Log {
const LEVEL_DEBUG = 'DEBUG';
const LEVEL_INFO = 'INFO';
const LEVEL_WARNING = 'WARNING';
const LEVEL_ERROR = 'ERROR';
private static $hostname = '';
private $backend;
private $progname;
public function __construct($backend, $options = array(), $progname = '') {
$this->progname = $progname;
$this->backend = Sihnon_Log_PluginFactory::create($backend, $options);
$this->log(self::LEVEL_INFO, "Logging started");
}
public function __destruct() {
$this->log(self::LEVEL_INFO, "Logging shutdown");
}
public function log($level, $message) {
$this->backend->log($level, time(), 0, self::$hostname, $this->progname, 0, $message);
}
public function debug($message) {
return $this->log(self::LEVEL_DEBUG, $message);
}
public function info($message) {
return $this->log(self::LEVEL_INFO, $message);
}
public function warning($message) {
return $this->log(self::LEVEL_WARNING, $message);
}
public function error($message) {
return $this->log(self::LEVEL_ERROR, $message);
}
public static function initialise() {
self::$hostname = trim(`hostname`);
}
}
SihnonFramework_Log::initialise();
?>