prefix = '[' . $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER['REMOTE_PORT'] . ':' . $msec[0] . ']'; } protected function getLogger() { if ($this->logger == null) { $this->logger = new FileLogger(FileLogger::DEBUG); if (version_compare(_PS_VERSION_, '1.7.0.0', '<')) { $path = '/log'; } elseif (version_compare(_PS_VERSION_, '1.7.3', '<=')) { $path = '/app/logs'; } else { $path = '/var/logs'; } $this->logger->setFilename(_PS_ROOT_DIR_ . $path . '/lscache.log'); } return $this->logger; } protected function logDebug($mesg, $debugLevel) { if ($this->isDebug >= $debugLevel) { if ($debugLevel == self::LEVEL_EXCEPTION) { ob_start(); debug_print_backtrace(0, 30); $trace = ob_get_contents(); ob_end_clean(); $mesg .= "\n" . $trace; } elseif ($debugLevel == self::LEVEL_UNEXPECTED) { $mesg = '!!!!! UNEXPECTED !!!!! ' . $mesg; } elseif ($debugLevel == self::LEVEL_NOTICE) { $mesg = '!!! NOTICE !!! ' . $mesg; } elseif ($debugLevel == self::LEVEL_TEMPORARY) { $mesg .= ' ###############'; } if ($debugLevel != self::LEVEL_TEMPORARY) { $mesg = str_replace("\n", ("\n" . $this->prefix . ' '), $mesg); } $this->getLogger()->logDebug($this->prefix . ' (' . $debugLevel . ') ' . $mesg); } } public static function setDebugLevel($debugLevel) { self::getInstance()->isDebug = $debugLevel; } public static function log($mesg, $debugLevel = 9) { self::getInstance()->logDebug($mesg, $debugLevel); } }