示例#1
0
 static function create($options)
 {
     $options = Hash::create($options, Hash::OPT_DEFAULT | Hash::OPT_ALLOW_UNDEFINED_KEY_GET | Hash::OPT_IGNORE_CASE);
     // フォーマット
     $class = sprintf('Nora\\System\\Logging\\Logger\\Formatter\\%sFormatter', ucfirst($options->getVal('type', 'string')));
     return new $class($options);
 }
示例#2
0
文件: Logging.php 项目: hossy78/nora
 public function __construct($settings, $context)
 {
     $this->_loggers = Hash::create([], Hash::OPT_DEFAULT | Hash::OPT_IGNORE_CASE);
     foreach ($settings as $k => $v) {
         $this->setup($k, $v, $context);
     }
 }
示例#3
0
文件: HashTest.php 项目: hossy78/nora
 public function testHash()
 {
     $hash = Hash::create(['a' => 1, 'b' => 2, 'C' => 3], Hash::OPT_SECURE | Hash::OPT_IGNORE_CASE);
     $this->assertTrue($hash->hasVal("c"));
     $hash->setVal("xx", "4");
     $this->assertTrue($hash->hasVal("xx"));
     $this->assertEquals($hash->getVal("xX"), "4");
 }
示例#4
0
文件: Session.php 项目: hossy78/nora
 public function __construct($cookie, KeyValueStoreIF $storage, $key = 'nora-session', $len = 64)
 {
     $this->_cookie = $cookie;
     $this->_storage = $storage;
     $this->_key = $key;
     $this->_len = $len;
     parent::__construct([], Hash::OPT_ALLOW_UNDEFINED_KEY_SET | Hash::OPT_ALLOW_UNDEFINED_KEY_GET);
 }
示例#5
0
 public static function create($spec)
 {
     if (is_object($spec) && !$spec instanceof ServiceSpec) {
         return new ServiceSpecObject($spec);
     }
     $opt = Hash::create($spec, Hash::OPT_IGNORE_CASE | Hash::OPT_ALLOW_UNDEFINED_KEY_GET);
     return new static($opt);
 }
示例#6
0
文件: Context.php 项目: hossy78/nora
 public static function init()
 {
     $context = new static();
     $context->_ENV = Hash::create($_ENV, Hash::OPT_ALLOW_ALL | Hash::OPT_IGNORE_CASE);
     $context->_GET = Hash::create($_GET, Hash::OPT_ALLOW_ALL | Hash::OPT_IGNORE_CASE);
     $context->_POST = Hash::create($_POST, Hash::OPT_ALLOW_ALL | Hash::OPT_IGNORE_CASE);
     $context->_COOKIE = Hash::create($_COOKIE, Hash::OPT_ALLOW_ALL | Hash::OPT_IGNORE_CASE);
     $context->setVal(['cache' => '/tmp']);
     return $context;
 }
示例#7
0
文件: Logger.php 项目: hossy78/nora
 /**
  * ロガーをビルドアップする
  */
 public static function build($options)
 {
     $options = Hash::create($options, Hash::OPT_ALLOW_UNDEFINED_KEY_GET);
     $logger = self::create($options->getVal('name', 'Nora'));
     foreach ($options->getVal('handlers', []) as $h) {
         $logger->addHandler(Handler::create($h));
     }
     if ($options->getVal('withPHPError', false)) {
         // ハンドラ系の登録
         set_error_handler([$logger, 'phpErrorHandler']);
         set_exception_handler([$logger, 'phpExceptionHandler']);
         register_shutdown_function([$logger, 'phpShutdownHandler']);
     }
     if ($options->getVal('asMainLogger', false)) {
         Nora::setLogger($logger);
     }
     return $logger;
 }
示例#8
0
文件: FileInfo.php 项目: hossy78/nora
 /**
  * パスをフォーマットする
  */
 public static function format($str)
 {
     static $data = false;
     if ($data === false) {
         $data['user'] = function ($params) {
             static $user = false;
             if ($user === false) {
                 $user = posix_getpwuid(posix_getuid())['name'];
             }
             return $user;
         };
         $data['time'] = function ($params) {
             $opt = Hash::create($params, Hash::OPT_ALLOW_UNDEFINED_KEY_GET);
             $format = $opt->getVal(0, 'Y-m-d G:i:s');
             return date($format, time());
         };
     }
     return Formatter::format($str, $data);
 }
示例#9
0
文件: Handler.php 项目: hossy78/nora
 static function create($options)
 {
     $options = Hash::create($options, Hash::OPT_DEFAULT | Hash::OPT_ALLOW_UNDEFINED_KEY_GET | Hash::OPT_IGNORE_CASE);
     // ハンドラクラス名を作成
     if (false === ($class = $options->getVal('class', false))) {
         $type = $options->getVal('type', 'echo');
         $class = sprintf('Nora\\System\\Logging\\Logger\\Handler\\%sHandler', ucfirst($type));
     }
     $handler = new $class($options);
     // レベルが設定されていたらレベルフィルターを仕込む
     if ($options->hasVal('level')) {
         $handler->addFilter(Filter::create(['level' => $options->getVal('level')]));
     }
     // フォーマッタが指定されていたら
     if ($options->hasVal('formatter')) {
         $formatter->setFormatter(Formatter::create($options->getVal('formatter')));
     }
     // プロセッサが指定されていたら
     foreach ($options->getVal('processer', []) as $p) {
         $handler->addProceccer($p);
     }
     return $handler;
 }
示例#10
0
文件: Provider.php 项目: hossy78/nora
 public function __construct($services = [])
 {
     $this->_specs = Hash::create([], Hash::OPT_STRICT | Hash::OPT_IGNORE_CASE | Hash::OPT_ALLOW_UNDEFINED_KEY_SET);
     $this->_cache = Hash::create([], Hash::OPT_STRICT | Hash::OPT_IGNORE_CASE | Hash::OPT_ALLOW_UNDEFINED_KEY_SET);
     $this->set($services);
 }
示例#11
0
文件: Util.php 项目: hossy78/nora
 public static function hash($data = [], $options = Hash::OPT_DEFAULT)
 {
     return Hash::create($data, $options);
 }
示例#12
0
文件: Request.php 项目: hossy78/nora
 public function __construct()
 {
     $this->_matched = Hash::create([], Hash::OPT_ALLOW_UNDEFINED_KEY_SET | Hash::OPT_ALLOW_UNDEFINED_KEY_GET);
 }
示例#13
0
 protected function initHandler(Hash $options)
 {
     $this->_stream = FileInfo::format($options->getVal('path', 'php://stdout'));
 }
示例#14
0
 private function formatTime(Log $log, $params)
 {
     $opt = Hash::create($params, Hash::OPT_ALLOW_UNDEFINED_KEY_GET);
     $format = $opt->getVal(0, 'Y-m-d G:i:s');
     return date($format, $log->getTime());
 }
示例#15
0
 protected function __construct(Hash $options)
 {
     $this->_level = LogLevel::toInt($options->getVal('level', 'debug'));
 }