Piwik\Common::printDebug PHP Méthode

printDebug() public static méthode

public static printDebug ( $info = '' )
    public static function printDebug($info = '')
    {
        if (isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG']) {
            if (!headers_sent()) {
                // prevent XSS in tracker debug output
                Common::sendHeader('Content-type: text/plain');
            }
            if (is_object($info)) {
                $info = var_export($info, true);
            }
            $logger = StaticContainer::get('Psr\\Log\\LoggerInterface');
            if (is_array($info) || is_object($info)) {
                $info = Common::sanitizeInputValues($info);
                $out = var_export($info, true);
                foreach (explode("\n", $out) as $line) {
                    $logger->debug($line);
                }
            } else {
                foreach (explode("\n", $info) as $line) {
                    $logger->debug($line);
                }
            }
        }
    }

Usage Example

Exemple #1
0
 public function outputResponse(Tracker $tracker)
 {
     if (!$tracker->shouldRecordStatistics()) {
         $this->outputApiResponse($tracker);
         Common::printDebug("Logging disabled, display transparent logo");
     } elseif (!$tracker->hasLoggedRequests()) {
         if (!$this->isHttpGetRequest() || !empty($_GET) || !empty($_POST)) {
             Common::sendResponseCode(400);
         }
         Common::printDebug("Empty request => Piwik page");
         echo "This resource is part of Piwik. Keep full control of your data with the leading free and open source <a href='https://piwik.org' target='_blank'>digital analytics platform</a> for web and mobile.";
     } else {
         $this->outputApiResponse($tracker);
         Common::printDebug("Nothing to notice => default behaviour");
     }
     Common::printDebug("End of the page.");
     if ($tracker->isDebugModeEnabled() && $tracker->isDatabaseConnected() && TrackerDb::isProfilingEnabled()) {
         $db = Tracker::getDatabase();
         $db->recordProfiling();
         Profiler::displayDbTrackerProfile($db);
     }
     if ($tracker->isDebugModeEnabled()) {
         Common::printDebug($_COOKIE);
         Common::printDebug((string) $this->timer);
     }
 }
All Usage Examples Of Piwik\Common::printDebug