diff --git a/config/global.ini.php b/config/global.ini.php index 94d45e6f942..553d6a9c143 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -400,6 +400,10 @@ ; this is useful when you want to do cross websites analysis use_third_party_id_cookie = 0 +; If tracking does not work for you or you are stuck finding an issue, you might want to enable the tracker debug mode. +; Once enabled (set to 1) messages will be logged to all loggers defined in "[log] log_writers" config. +debug = 0 + ; There is a feature in the Tracking API that lets you create new visit at any given time, for example if you know that a different user/customer is using ; the app then you would want to tell Piwik to create a new visit (even though both users are using the same browser/computer). ; To prevent abuse and easy creation of fake visits, this feature requires admin token_auth by default diff --git a/core/Common.php b/core/Common.php index b25047f0782..ec31f88280f 100644 --- a/core/Common.php +++ b/core/Common.php @@ -31,7 +31,6 @@ class Common public static $isCliMode = null; - /* * Database */ @@ -1062,17 +1061,19 @@ static public function destroy(&$var) static public function printDebug($info = '') { if (isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG']) { - if(is_object($info)) { + + if (is_object($info)) { $info = var_export($info, true); } + + Log::getInstance()->setLogLevel(Log::DEBUG); + if (is_array($info)) { - print("
"); $info = Common::sanitizeInputValues($info); $out = var_export($info, true); - echo $out; - print(""); + Log::debug($out); } else { - print(htmlspecialchars($info, ENT_QUOTES) . "
', '', $resultTask)); + } + Common::printDebug('Finished Scheduled Tasks.'); } else { Common::printDebug("-> Scheduled tasks not triggered."); @@ -851,7 +854,7 @@ protected function trackRequest($params, $tokenAuth) Common::printDebug("The request is invalid: empty request, or maybe tracking is disabled in the config.ini.php via record_statistics=0"); } } catch (DbException $e) { - Common::printDebug("" . $e->getMessage() . ""); + Common::printDebug("Exception: " . $e->getMessage()); $this->exitWithException($e, $isAuthenticated); } catch (Exception $e) { $this->exitWithException($e, $isAuthenticated); diff --git a/piwik.php b/piwik.php index 539b0d40a61..a123987a26e 100644 --- a/piwik.php +++ b/piwik.php @@ -12,7 +12,6 @@ use Piwik\Timer; use Piwik\Tracker; -$GLOBALS['PIWIK_TRACKER_DEBUG'] = false; $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] = false; define('PIWIK_ENABLE_TRACKING', true); @@ -84,6 +83,9 @@ ob_start(); } +\Piwik\FrontController::createConfigObject(); + +$GLOBALS['PIWIK_TRACKER_DEBUG'] = \Piwik\Config::getInstance()->Tracker['debug']; if ($GLOBALS['PIWIK_TRACKER_DEBUG'] === true) { require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; @@ -93,10 +95,10 @@ \Piwik\ExceptionHandler::setUp(); $timer = new Timer(); - Common::printDebug("Debug enabled - Input parameters:
" . var_export($_GET, true)); + Common::printDebug("Debug enabled - Input parameters: "); + Common::printDebug(var_export($_GET, true)); \Piwik\Tracker\Db::enableProfiling(); - \Piwik\FrontController::createConfigObject(); } if (!defined('PIWIK_ENABLE_TRACKING') || PIWIK_ENABLE_TRACKING) {