diff --git a/classes/Log.php b/classes/Log.php index 808d2b1..26d57ae 100644 --- a/classes/Log.php +++ b/classes/Log.php @@ -116,36 +116,43 @@ class Log */ private static function write($log_type, $message, $format = true, $time = false) { - $log_path = LOG_PATH . date('Y/m/d/', ($time == false ? time() : $time)); + $config = Config::getInstance(); - try + if ($config->pickles['logging'] === true) { - if (!file_exists($log_path)) + $log_path = LOG_PATH . date('Y/m/d/', ($time == false ? time() : $time)); + + try { - mkdir($log_path, 0755, true); + if (!file_exists($log_path)) + { + mkdir($log_path, 0755, true); + } + + $log_file = $log_path . $log_type . '.log'; + + $message .= "\n"; + + if ($format == true) + { + $backtrace = debug_backtrace(); + rsort($backtrace); + $frame = $backtrace[strpos($backtrace[0]['file'], 'index.php') === false ? 0 : 1]; + + return file_put_contents($log_file, date('H:i:s') . ' ' . str_replace(getcwd(), '', $frame['file']) . ':' . $frame['line'] . ' ' . $message, FILE_APPEND); + } + else + { + return file_put_contents($log_file, $message, FILE_APPEND); + } } - - $log_file = $log_path . $log_type . '.log'; - - $message .= "\n"; - - if ($format == true) + catch (ErrorException $exception) { - $backtrace = debug_backtrace(); - rsort($backtrace); - $frame = $backtrace[strpos($backtrace[0]['file'], 'index.php') === false ? 0 : 1]; - - return file_put_contents($log_file, date('H:i:s') . ' ' . str_replace(getcwd(), '', $frame['file']) . ':' . $frame['line'] . ' ' . $message, FILE_APPEND); - } - else - { - return file_put_contents($log_file, $message, FILE_APPEND); + return false; } } - catch (ErrorException $exception) - { - return false; - } + + return false; } }