public function stopQuery() { $this->queries[$this->currentQuery]['executionMS'] = microtime(true) - $this->start; \Logkit\Logger::ins('_sql')->info(json_encode($this->queries[$this->currentQuery])); if ($this->currentQuery % self::FLUSH_COUNT === 0) { $this->queries = []; } }
public static function ins($group = null) { if (!isset($group)) { $group = Queue::$default; } if (isset(Queue::$instances[$group])) { return Queue::$instances[$group]; } $config = \Yaf\Application::app()->getConfig()->queue; $config = isset($config) ? $config->{$group} : null; if (!isset($config)) { throw new Exception('Failed to load Queue group: ' . $group); } $driver = 'Queue\\Driver\\' . ucfirst($config->driver); if (!class_exists($driver)) { throw new Exception('Driver ' . $driver . ' not found.'); } $instance = new $driver($config); $instance->setLogger(Logger::ins('_queue')); Queue::$instances[$group] = $instance; return Queue::$instances[$group]; }
private function __construct($mongoConfig) { $this->logger = \Logkit\Logger::ins('mongo'); AnnotationDriver::registerAnnotationClasses(); //获取ODM配置 $ODMConfig = \Yaf\Application::app()->getConfig()->ODM; if (!$ODMConfig) { throw new Exception('The ODM config not found.'); } //连接mongodb $dsn = 'mongodb://' . $mongoConfig->host . ':' . $mongoConfig->port; $options = $mongoConfig->options->toArray(); $connection = new Connection($dsn, $options); //配置ODM $config = new Configuration(); $config->setProxyDir($ODMConfig->proxiesDir); $config->setProxyNamespace('Proxies'); $config->setHydratorDir($ODMConfig->hydratorsDir); $config->setHydratorNamespace('Hydrators'); $config->setMetadataDriverImpl(AnnotationDriver::create($ODMConfig->documentsDir)); $this->ducumentManager = DocumentManager::create($connection, $config); }
/** * 日志记录,可被重载。 * * @param mixed $log * 输入日志 * @return mixed */ protected function log($log) { if ($this->debug) { if (is_array($log)) { $log = print_r($log, true); } return \Logkit\Logger::ins('weixin')->info($log); } }
public function write() { if (headers_sent() || $this->destroyed) { return false; } try { return $this->_write(); } catch (Exception $e) { Logger::ins('session')->error($e->getMessage()); return false; } }