/** * Constructor * * @param integer $level the debug level */ public function __construct($level, ORM\EntityManager $em) { // taking timestamp to stop execution time $this->created = microtime(TRUE); // saving debug level $this->level = $level; // starting logging of sql queries $this->sqlLogger = new Logging\DebugStack(); $em->getConnection()->getConfiguration()->setSQLLogger($this->sqlLogger); if (isset(self::$instance)) { throw new \Exception('Debugging has already been started. Please use the static functions!'); } self::$instance = $this; }
/** * Deactivate debugging (for http server) * @return boolean */ public static function deactivate() { if (self::$instance) { self::$instance->attachSqlLogger(null); self::$instance = null; } }