mirror of
https://github.com/cytopia/devilbox.git
synced 2024-12-26 16:01:05 +00:00
50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
|
|
final class log
|
|
{
|
|
protected static $_instances = array();
|
|
protected static $_instance = null;
|
|
|
|
protected $_levels = array(
|
|
'error' => 1,
|
|
'notice' => 2,
|
|
'info' => 3,
|
|
'warning' => 4,
|
|
'debug' => 5
|
|
);
|
|
|
|
const INFO = 'info';
|
|
const DEBUG = 'debug';
|
|
const ERROR = 'error';
|
|
const WARNING = 'warning';
|
|
const NOTICE = 'notice';
|
|
|
|
public static function instance()
|
|
{
|
|
if (!isset(self::$_instance)) {
|
|
self::$_instance = new self;
|
|
}
|
|
|
|
return self::$_instance;
|
|
}
|
|
|
|
public static function factory($driver = null)
|
|
{
|
|
$driver = isset($driver) ? $driver : App::instance()->config['log']['driver'];
|
|
|
|
if (!isset(self::$_instances[$driver])) {
|
|
include_once(App::instance()->drivers.'log/'.(strtolower($driver)).'.php');
|
|
|
|
$class = ucwords(strtolower($driver)).'Log';
|
|
self::$_instances[$driver] = new $class;
|
|
}
|
|
|
|
return self::$_instances[$driver];
|
|
}
|
|
|
|
public function __get($key)
|
|
{
|
|
return isset($this->_levels[$key]) ? $this->_levels[$key] : 0;
|
|
}
|
|
}
|