Logginger class.
Protected constructor since this is a static class.
NULL
protected function __construct()
{
// Nothing here
}
Returns an instance of the requested log configuration.
| Type | Description |
|---|---|
| string | (optional) Log configuration name |
mako\log\Adapter
public static function instance($name = null)
{
$config = Config::get('log');
$name = ($name === null) ? $config['default'] : $name;
if(!isset(static::$instances[$name]))
{
if(isset($config['configurations'][$name]) === false)
{
throw new RuntimeException(vsprintf("%s(): '%s' has not been defined in the log configuration.", array(__METHOD__, $name)));
}
$class = '\mako\log\\' . $config['configurations'][$name]['type'];
static::$instances[$name] = new $class($config['configurations'][$name]);
}
return static::$instances[$name];
}
Magic shortcut for writing to logs.
| Type | Description |
|---|---|
| string | Name of the log type |
| string | Method arguments |
boolean
public static function __callStatic($name, $arguments)
{
if(!defined('static::' . strtoupper($name)))
{
throw new RuntimeException(vsprintf("%s(): Invalid log type.", array(__METHOD__)));
}
return static::instance()->write($arguments[0], constant('static::' . strtoupper($name)));
}