public function logQuery($sql) { if (isset(static::$configs['DEBUG']) && isset(static::$configs['DEBUG_LEVEL'])) { $logString = 'Begin:' . date('Y-m-d H:i:s', $this->queryBeginTime) . "\n"; $logString .= 'SQL: ' . $sql . "\n"; switch (static::$configs['DEBUG_LEVEL']) { case 2: //looks ugly $tempE = new \Exception(); $logString .= "Trace:\n" . $tempE->getTraceAsString() . "\n"; continue; case 1: default: continue; } $logString .= 'End:' . date('Y-m-d H:i:s', $this->queryEndTime) . ' Total:' . sprintf('%.3f', ($this->queryEndTime - $this->queryBeginTime) * 1000) . 'ms' . "\n"; \Log\Handler::instance('db')->log($logString); } }
public function __construct($message, $code = null) { L::log($message, L::LOG_EXCEPTION, 'exception-mysql'); return parent::__construct($message, $code); }