Beispiel #1
0
 /**
  * @see Log
  */
 public function flush($logs, $id, $stdout)
 {
     foreach ($logs as $log) {
         try {
             $vars = $options = array();
             foreach (module_const_array('params') as $param) {
                 list($name, $value) = array_map('trim', explode(',', $param, 2));
                 $vars[$name] = $value;
             }
             $vars['level'] = $log->fm_level();
             $value = $log->value();
             if (is_array($value)) {
                 $value = array_shift($value);
             }
             switch ($log->fm_level()) {
                 case 'error':
                 case 'warn':
                 case 'info':
                     $vars['priv'] = 1;
                     $vars['message'] = sprintf("%s:%s %s", pathinfo($log->file(), PATHINFO_FILENAME), $log->line(), str($value));
                     break;
             }
             if (isset($vars['message'])) {
                 $data = http_build_query($vars);
                 $header = array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($data));
                 $options = array('http' => array('method' => 'POST', 'header' => implode("\r\n", $header), 'content' => $data));
                 file_get_contents(module_const('url'), false, stream_context_create($options));
             }
         } catch (Exception $e) {
         }
         // print(sprintf('console.%s("[%s:%d]",%s);',$log->fm_level(),$log->file(),$log->line(),str_replace("\n","\\n",Text::to_json($log->value()))));
     }
 }
Beispiel #2
0
 public static function __callStatic($name, array $args)
 {
     if (empty($args)) {
         return module_const($name);
     } else {
         $arg = array_shift($args);
         return module_const($name, $arg);
     }
 }
 /**
  * linktitleHandler
  */
 public static function linktitleHandler($url)
 {
     if (module_const('is_cache', false)) {
         $store_key = array('__hatenaformat_linktitlehandler', $url);
         if (Store::has($store_key)) {
             return Store::get($store_key);
         }
     }
     if (Tag::setof($title, Http::read($url), 'title')) {
         $url = $title->value();
         if (module_const('is_cache', false)) {
             Store::set($store_key, $url, self::CACHE_EXPIRE);
         }
     }
     return $url;
 }
Beispiel #4
0
 public function atom()
 {
     Atom::convert(module_const('sitename', 'Planet'), url(), C(PlanetEntry)->find_all(new Paginator(20), Q::order('-updated')))->output();
 }
Beispiel #5
0
 public static function __import__()
 {
     self::$__cmd_path__ = module_const('cmd_path', '/usr/bin/svn');
     self::$__look_cmd_path__ = module_const('look_cmd_path', '/usr/bin/svnlook');
     self::$_lang_ = module_const('lang', 'ja_JP.UTF-8');
 }