Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenaka Moorthi <benaka.moorthi@gmail.com>2013-10-07 00:47:11 +0400
committerBenaka Moorthi <benaka.moorthi@gmail.com>2013-10-07 00:47:22 +0400
commit6c11ad21c86a3bac8111d5a4c08bc635984d2129 (patch)
treeff7d27edc8483e65ee0a39f0247e011e1855f843
parent57501bfc33ed680cdde8c9177e8dc0ea42005011 (diff)
Removed Piwik::log and replace with calls to Log::... functions. Also changed logging level on travis.
-rw-r--r--config/global.ini.php2
-rw-r--r--core/Archive.php14
-rw-r--r--core/ArchiveProcessor.php6
-rw-r--r--core/ArchiveProcessor/Rules.php5
-rw-r--r--core/Config.php3
-rw-r--r--core/DataAccess/ArchiveSelector.php9
-rw-r--r--core/DataAccess/ArchiveWriter.php5
-rw-r--r--core/Db/BatchInsert.php5
-rw-r--r--core/FrontController.php2
-rw-r--r--core/Http.php12
-rw-r--r--core/Piwik.php17
-rw-r--r--core/Profiler.php8
-rw-r--r--core/Session.php3
-rw-r--r--core/ViewDataTable.php2
-rw-r--r--misc/cron/archive.php5
-rwxr-xr-xmisc/others/geoipUpdateRows.php35
-rw-r--r--misc/others/test_generateLotsVisitsWebsites.php8
-rwxr-xr-xplugins/PrivacyManager/LogDataPurger.php6
-rw-r--r--plugins/SEO/RankChecker.php5
-rwxr-xr-xplugins/UserCountry/GeoIPAutoUpdater.php15
-rwxr-xr-xplugins/UserCountry/LocationProvider/GeoIp/Php.php5
-rw-r--r--tests/PHPUnit/Integration/ArchiveCronTest.php2
-rw-r--r--tests/PHPUnit/Plugins/UserCountryTest.php2
-rw-r--r--tests/PHPUnit/config.ini.travis.php3
24 files changed, 86 insertions, 93 deletions
diff --git a/config/global.ini.php b/config/global.ini.php
index 3c12a27048..a415b7057e 100644
--- a/config/global.ini.php
+++ b/config/global.ini.php
@@ -47,7 +47,7 @@ always_archive_data_range = 0;
; if set to 1, all the SQL queries will be recorded by the profiler
; and a profiling summary will be printed at the end of the request
-; NOTE: you must also set [log] logger_message[] = "screen" to enable the profiler to print on screen
+; NOTE: you must also set [log] log_writers[] = "screen" to enable the profiler to print on screen
enable_sql_profiler = 0
; if set to 1, a Piwik tracking code will be included in the Piwik UI footer and will track visits, pages, etc. to idsite = 1
diff --git a/core/Archive.php b/core/Archive.php
index d4fa564dda..fad9666809 100644
--- a/core/Archive.php
+++ b/core/Archive.php
@@ -14,6 +14,7 @@ use Piwik\Period\Range;
use Piwik\Piwik;
use Piwik\Metrics;
use Piwik\Date;
+use Piwik\Log;
use Piwik\ArchiveProcessor\Rules;
use Piwik\DataAccess\ArchiveSelector;
@@ -456,15 +457,15 @@ class Archive
// we already know there are no stats for this period
// we add one day to make sure we don't miss the day of the website creation
if ($twoDaysAfterPeriod->isEarlier($site->getCreationDate())) {
- $archiveDesc = $this->getArchiveDescriptor($idSite, $period);
- Piwik::log("Archive $archiveDesc skipped, archive is before the website was created.");
+ Log::verbose("Archive site %s, %s (%s) skipped, archive is before the website was created.",
+ $idSite, $period->getLabel(), $period->getPrettyString());
continue;
}
// if the starting date is in the future we know there is no visiidsite = ?t
if ($twoDaysBeforePeriod->isLater($today)) {
- $archiveDesc = $this->getArchiveDescriptor($idSite, $period);
- Piwik::log("Archive $archiveDesc skipped, archive is after today.");
+ Log::verbose("Archive site %s, %s (%s) skipped, archive is after today.",
+ $idSite, $period->getLabel(), $period->getPrettyString());
continue;
}
@@ -578,11 +579,6 @@ class Archive
return round((float)$value, 2);
}
- private function getArchiveDescriptor($idSite, $period)
- {
- return "site $idSite, {$period->getLabel()} ({$period->getPrettyString()})";
- }
-
private function uncompress($data)
{
return @gzuncompress($data);
diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php
index 74ec976335..f73f74cbbf 100644
--- a/core/ArchiveProcessor.php
+++ b/core/ArchiveProcessor.php
@@ -21,6 +21,7 @@ use Piwik\Db;
use Piwik\DataAccess\ArchiveSelector;
use Piwik\DataAccess\ArchiveWriter;
use Piwik\DataAccess\LogAggregator;
+use Piwik\Log;
/**
* The ArchiveProcessor class is used by the Archive object to make sure the given Archive is processed and available in the DB.
@@ -347,7 +348,8 @@ abstract class ArchiveProcessor
if ($this->isArchiveTemporary()) {
$temporary = 'temporary archive';
}
- Piwik::log(sprintf("'%s, idSite = %d (%s), segment '%s', report = '%s', UTC datetime [%s -> %s]",
+ Log::verbose(
+ "'%s, idSite = %d (%s), segment '%s', report = '%s', UTC datetime [%s -> %s]",
$this->getPeriod()->getLabel(),
$this->getSite()->getId(),
$temporary,
@@ -355,7 +357,7 @@ abstract class ArchiveProcessor
$requestedPlugin,
$this->getDateStart()->getDateStartUTC(),
$this->getDateEnd()->getDateEndUTC()
- ));
+ );
}
/**
diff --git a/core/ArchiveProcessor/Rules.php b/core/ArchiveProcessor/Rules.php
index 73949ee102..39191c4794 100644
--- a/core/ArchiveProcessor/Rules.php
+++ b/core/ArchiveProcessor/Rules.php
@@ -19,6 +19,7 @@ use Piwik\Segment;
use Piwik\SettingsPiwik;
use Piwik\SettingsServer;
use Piwik\Site;
+use Piwik\Log;
use Piwik\Tracker\Cache;
/**
@@ -142,7 +143,7 @@ class Rules
return $purgeArchivesOlderThan;
}
- Piwik::log("Purging temporary archives: skipped.");
+ Log::info("Purging temporary archives: skipped.");
return false;
}
@@ -203,7 +204,7 @@ class Rules
&& $isArchivingDisabled
&& Config::getInstance()->General['browser_archiving_disabled_enforce']
) {
- Piwik::log("Archiving is disabled because of config setting browser_archiving_disabled_enforce=1");
+ Log::debug("Archiving is disabled because of config setting browser_archiving_disabled_enforce=1");
return true;
}
return false;
diff --git a/core/Config.php b/core/Config.php
index 42399390ce..2d64797ac7 100644
--- a/core/Config.php
+++ b/core/Config.php
@@ -56,8 +56,6 @@ class Config
{
if (self::$instance == null) {
self::$instance = new self;
-
- Piwik_PostTestEvent('Config.createConfigSingleton', array(self::$instance));
}
return self::$instance;
}
@@ -213,7 +211,6 @@ class Config
$this->pathGlobal = self::getGlobalConfigPath();
$this->pathLocal = self::getLocalConfigPath();
-
}
/**
diff --git a/core/DataAccess/ArchiveSelector.php b/core/DataAccess/ArchiveSelector.php
index 6b1f716243..21692f460a 100644
--- a/core/DataAccess/ArchiveSelector.php
+++ b/core/DataAccess/ArchiveSelector.php
@@ -22,6 +22,7 @@ use Piwik\Segment;
use Piwik\Site;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Db;
+use Piwik\Log;
/**
* Data Access object used to query archives
@@ -292,8 +293,8 @@ class ArchiveSelector
}
self::deleteArchivesWithPeriodRange($dateStart);
- Piwik::log("Purging temporary archives: done [ purged archives older than $purgeArchivesOlderThan in "
- . $dateStart->toString("Y-m") . " ] [Deleted IDs: " . implode(',', $idArchivesToDelete) . "]");
+ Log::debug("Purging temporary archives: done [ purged archives older than %s in %s ] [Deleted IDs: %s]",
+ $purgeArchivesOlderThan, $dateStart->toString("Y-m"), implode(',', $idArchivesToDelete));
}
/*
@@ -307,7 +308,7 @@ class ArchiveSelector
$bind = array(Piwik::$idPeriods['range'], $yesterday);
$numericTable = ArchiveTableCreator::getNumericTable($date);
Db::query(sprintf($query, $numericTable), $bind);
- Piwik::log("Purging Custom Range archives: done [ purged archives older than $yesterday from $numericTable / blob ]");
+ Log::debug("Purging Custom Range archives: done [ purged archives older than %s from %s / blob ]", $yesterday, $numericTable);
try {
Db::query(sprintf($query, ArchiveTableCreator::getBlobTable($date)), $bind);
} catch (Exception $e) {
@@ -345,4 +346,4 @@ class ArchiveSelector
}
return $idArchivesToDelete;
}
-}
+} \ No newline at end of file
diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php
index 17f4bff9b5..deae286948 100644
--- a/core/DataAccess/ArchiveWriter.php
+++ b/core/DataAccess/ArchiveWriter.php
@@ -21,6 +21,7 @@ use Piwik\Period;
use Piwik\Piwik;
use Piwik\Segment;
use Piwik\SettingsPiwik;
+use Piwik\Log;
/**
* This class is used to create a new Archive.
@@ -97,7 +98,7 @@ class ArchiveWriter
$lockName = $this->getArchiveProcessorLockName();
$result = Db::getDbLock($lockName, $maxRetries = 30);
if (!$result) {
- Piwik::log("SELECT GET_LOCK failed to acquire lock. Proceeding anyway.");
+ Log::debug("SELECT GET_LOCK failed to acquire lock. Proceeding anyway.");
}
}
@@ -131,7 +132,7 @@ class ArchiveWriter
} catch (Exception $ex) {
if (Db::get()->isErrNo($ex, 1213)) {
$deadlockInfo = \Piwik\Db::fetchAll("SHOW ENGINE INNODB STATUS");
- Piwik::log("DEADLOCK INFO: " . print_r($deadlockInfo));
+ Log::debug("DEADLOCK INFO: " . print_r($deadlockInfo));
}
throw $ex;
}
diff --git a/core/Db/BatchInsert.php b/core/Db/BatchInsert.php
index cd339e215e..c7bc3184de 100644
--- a/core/Db/BatchInsert.php
+++ b/core/Db/BatchInsert.php
@@ -14,6 +14,7 @@ use Exception;
use Piwik\AssetManager;
use Piwik\Common;
use Piwik\Config;
+use Piwik\Log;
use Piwik\Db;
use Piwik\DbHelper;
use Piwik\Piwik;
@@ -93,7 +94,7 @@ class BatchInsert
return true;
}
} catch (Exception $e) {
- Piwik::log(sprintf("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was: %s", $e->getMessage()));
+ Log::info("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was: %s", $e->getMessage());
if ($throwException) {
throw $e;
@@ -187,7 +188,7 @@ class BatchInsert
$code = $e->getCode();
$message = $e->getMessage() . ($code ? "[$code]" : '');
if (!Db::get()->isErrNo($e, '1148')) {
- Piwik::log(sprintf("LOAD DATA INFILE failed... Error was: %s", $message));
+ Log::info("LOAD DATA INFILE failed... Error was: %s", $message);
}
$exceptions[] = "\n Try #" . (count($exceptions) + 1) . ': ' . $queryStart . ": " . $message;
}
diff --git a/core/FrontController.php b/core/FrontController.php
index f74cf95501..b4b91d625b 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -174,7 +174,7 @@ class FrontController
if (class_exists('Piwik\\Profiler')) {
Profiler::displayDbProfileReport();
Profiler::printQueryCount();
- Piwik::log(Registry::get('timer'));
+ Log::debug(Registry::get('timer'));
}
} catch (Exception $e) {
}
diff --git a/core/Http.php b/core/Http.php
index a35b5ce9d2..0f45c25637 100644
--- a/core/Http.php
+++ b/core/Http.php
@@ -11,6 +11,7 @@
namespace Piwik;
use Exception;
+use Piwik\Log;
/**
* Server-side http client to retrieve content from remote servers, and optionally save to a local file.
@@ -576,15 +577,14 @@ class Http
}
if ($expectedFileSize == 0) {
- Piwik::log(sprintf("HEAD request for '%s' failed, got following: %s", $url, print_r($expectedFileSizeResult, true)));
+ Log::info("HEAD request for '%s' failed, got following: %s", $url, print_r($expectedFileSizeResult, true));
throw new Exception(Piwik_Translate('General_DownloadFail_HttpRequestFail'));
}
Piwik_SetOption($downloadOption, $expectedFileSize);
} else {
$expectedFileSize = (int)Piwik_GetOption($downloadOption);
- if ($expectedFileSize === false) // sanity check
- {
+ if ($expectedFileSize === false) { // sanity check
throw new Exception("Trying to continue a download that never started?! That's not supposed to happen...");
}
}
@@ -615,8 +615,8 @@ class Http
|| $result['status'] > 299
) {
$result['data'] = self::truncateStr($result['data'], 1024);
- Piwik::log("Failed to download range '" . $byteRange[0] . "-" . $byteRange[1]
- . "' of file from url '$url'. Got result: " . print_r($result, true));
+ Log::info("Failed to download range '%s-%s' of file from url '%s'. Got result: %s",
+ $byteRange[0], $byteRange[1], $url, print_r($result, true));
throw new Exception(Piwik_Translate('General_DownloadFail_HttpRequestFail'));
}
@@ -700,4 +700,4 @@ class Http
}
return $str;
}
-}
+} \ No newline at end of file
diff --git a/core/Piwik.php b/core/Piwik.php
index 4223833534..4a4d2b67af 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -51,23 +51,6 @@ class Piwik
const LABEL_ID_GOAL_IS_ECOMMERCE_ORDER = 'ecommerceOrder';
/**
- * Logging and error handling
- *
- * @var bool|null
- */
- public static $shouldLog = null;
-
- /**
- * Log a message TODO: remove
- *
- * @param string $message
- */
- static public function log($message = '')
- {
- Log::info($message);
- }
-
- /**
* Trigger E_USER_ERROR with optional message
*
* @param string $message
diff --git a/core/Profiler.php b/core/Profiler.php
index b79bc068ce..4ad407f3ee 100644
--- a/core/Profiler.php
+++ b/core/Profiler.php
@@ -10,6 +10,8 @@
*/
namespace Piwik;
+use Piwik\Log;
+
/**
* Class Profiler helps with measuring memory, and profiling the database.
* To enable set in your config.ini.php
@@ -86,7 +88,7 @@ class Profiler
$str .= '(Average query length: ' . round($totalTime / $queryCount, 3) . ' seconds)';
$str .= '<br />Queries per second: ' . round($queryCount / $totalTime, 1);
$str .= '<br />Longest query length: ' . round($longestTime, 3) . " seconds (<code>$longestQuery</code>)";
- Piwik::log($str);
+ Log::debug($str);
self::getSqlProfilingQueryBreakdownOutput($infoIndexedByQuery);
}
@@ -135,7 +137,7 @@ class Profiler
{
$totalTime = self::getDbElapsedSecs();
$queryCount = Profiler::getQueryCount();
- Piwik::log(sprintf("Total queries = %d (total sql time = %.2fs)", $queryCount, $totalTime));
+ Log::debug(sprintf("Total queries = %d (total sql time = %.2fs)", $queryCount, $totalTime));
}
/**
@@ -179,6 +181,6 @@ class Profiler
$query = preg_replace('/([\t\n\r ]+)/', ' ', $query);
$output .= "Executed <b>$count</b> time" . ($count == 1 ? '' : 's') . " in <b>" . $timeMs . "ms</b> $avgTimeString <pre>\t$query</pre>";
}
- Piwik::log($output);
+ Log::debug($output);
}
} \ No newline at end of file
diff --git a/core/Session.php b/core/Session.php
index fd17a48e59..a19a546dab 100644
--- a/core/Session.php
+++ b/core/Session.php
@@ -11,6 +11,7 @@
namespace Piwik;
use Exception;
+use Piwik\Log;
use Piwik\Session\SaveHandler\DbTable;
use Zend_Session;
@@ -120,7 +121,7 @@ class Session extends Zend_Session
Zend_Session::start();
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
} catch (Exception $e) {
- Piwik::log('Unable to start session: ' . $e->getMessage());
+ Log::warning('Unable to start session: ' . $e->getMessage());
$enableDbSessions = '';
if (DbHelper::isInstalled()) {
diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php
index 5d6a6f5c89..4c3ef0c0ff 100644
--- a/core/ViewDataTable.php
+++ b/core/ViewDataTable.php
@@ -1126,7 +1126,7 @@ class ViewDataTable
} catch (NoAccessException $e) {
throw $e;
} catch (\Exception $e) {
- Piwik::log("Failed to get data from API: " . $e->getMessage());
+ Log::warning("Failed to get data from API: " . $e->getMessage());
$loadingError = array('message' => $e->getMessage());
}
diff --git a/misc/cron/archive.php b/misc/cron/archive.php
index 40eb2ba1d2..1fdae6d839 100644
--- a/misc/cron/archive.php
+++ b/misc/cron/archive.php
@@ -11,6 +11,7 @@ use Piwik\Plugins\SitesManager\API as APISitesManager;
use Piwik\Timer;
use Piwik\Url;
use Piwik\Version;
+use Piwik\Log;
$USAGE = "
Usage:
@@ -355,7 +356,7 @@ class CronArchive
$requestsWebsite = $this->requests - $requestsBefore;
$debug = $this->shouldArchiveAllWebsites ? ", last days = $visitsAllDays visits" : "";
- Piwik::log("Archived website id = $idsite, today = $visitsToday visits"
+ Log::info("Archived website id = $idsite, today = $visitsToday visits"
. $debug . ", $requestsWebsite API requests, "
. $timerWebsite->__toString()
. " [" . ($websitesWithVisitsSinceLastRun + $skipped) . "/"
@@ -557,7 +558,7 @@ class CronArchive
{
$this->output .= $m . "\n";
try {
- Piwik::log($m);
+ Log::info($m);
} catch(Exception $e) {
print($m . "\n");
}
diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php
index 2369f955d8..ff4613ee4a 100755
--- a/misc/others/geoipUpdateRows.php
+++ b/misc/others/geoipUpdateRows.php
@@ -4,6 +4,7 @@ use Piwik\Config;
use Piwik\Db;
use Piwik\FrontController;
use Piwik\IP;
+use Piwik\Log;
use Piwik\Piwik;
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Pecl;
use Piwik\Plugins\UserCountry\LocationProvider;
@@ -34,7 +35,8 @@ require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
$GLOBALS['PIWIK_TRACKER_DEBUG'] = false;
define('PIWIK_ENABLE_DISPATCH', false);
-Config::getInstance()->log['logger_message'][] = 'screen';
+Config::getInstance()->log['log_writers'][] = 'screen';
+Config::getInstance()->log['log_level'] = 'VERBOSE';
FrontController::getInstance()->init();
$query = "SELECT count(*) FROM " . Common::prefixTable('log_visit');
@@ -45,7 +47,7 @@ if (!Common::isPhpCliMode()) {
try {
Piwik::checkUserIsSuperUser();
} catch (Exception $e) {
- Piwik::log('[error] You must be logged in as Super User to run this script. Please login in to Piwik and refresh this page.');
+ Log::error('[error] You must be logged in as Super User to run this script. Please login in to Piwik and refresh this page.');
exit;
}
// the 'start' query param will be supplied by the AJAX requests, so if it's not there, the
@@ -111,7 +113,7 @@ if (!Common::isPhpCliMode()) {
function geoipUpdateError($message)
{
- Piwik::log($message);
+ Log::error($message);
if (!Common::isPhpCliMode()) {
@header('HTTP/1.1 500 Internal Server Error', $replace = true, $responseCode = 500);
}
@@ -126,7 +128,7 @@ $displayNotes = $start == 0;
$provider = new Pecl();
if (!$provider->isAvailable()) {
if ($displayNotes) {
- Piwik::log("[note] The GeoIP PECL extension is not installed.");
+ Log::info("[note] The GeoIP PECL extension is not installed.");
}
$provider = null;
@@ -134,10 +136,10 @@ if (!$provider->isAvailable()) {
$workingOrError = $provider->isWorking();
if ($workingOrError !== true) {
if ($displayNotes) {
- Piwik::log("[note] The GeoIP PECL extension is broken: $workingOrError");
+ Log::info("[note] The GeoIP PECL extension is broken: $workingOrError");
}
if (Common::isPhpCliMode()) {
- Piwik::log("[note] Make sure your command line PHP is configured to use the PECL extension.");
+ Log::info("[note] Make sure your command line PHP is configured to use the PECL extension.");
}
$provider = null;
}
@@ -146,20 +148,20 @@ if (!$provider->isAvailable()) {
// use php api if pecl extension cannot be used
if (is_null($provider)) {
if ($displayNotes) {
- Piwik::log("[note] Falling back to PHP API. This may become too slow for you. If so, you can read this link on how to install the PECL extension: http://piwik.org/faq/how-to/#faq_164");
+ Log::info("[note] Falling back to PHP API. This may become too slow for you. If so, you can read this link on how to install the PECL extension: http://piwik.org/faq/how-to/#faq_164");
}
$provider = new Php();
if (!$provider->isAvailable()) {
if ($displayNotes) {
- Piwik::log("[note] The GeoIP PHP API is not available. This means you do not have a GeoIP location database in your ./misc directory. The database must be named either GeoIP.dat or GeoIPCity.dat based on the type of database it is.");
+ Log::info("[note] The GeoIP PHP API is not available. This means you do not have a GeoIP location database in your ./misc directory. The database must be named either GeoIP.dat or GeoIPCity.dat based on the type of database it is.");
}
$provider = null;
} else {
$workingOrError = $provider->isWorking();
if ($workingOrError !== true) {
if ($displayNotes) {
- Piwik::log("[note] The GeoIP PHP API is broken: $workingOrError");
+ Log::info("[note] The GeoIP PHP API is broken: $workingOrError");
}
$provider = null;
}
@@ -172,7 +174,7 @@ if (is_null($provider)) {
$info = $provider->getInfo();
if ($displayNotes) {
- Piwik::log("[note] Found working provider: {$info['id']}");
+ Log::info("[note] Found working provider: {$info['id']}");
}
// perform update
@@ -183,7 +185,7 @@ $logVisitFieldsToUpdate = array('location_country' => LocationProvider::COUNTR
'location_longitude' => LocationProvider::LONGITUDE_KEY);
if ($displayNotes) {
- Piwik::log("\n$count rows to process in " . Common::prefixTable('log_visit')
+ Log::info("\n$count rows to process in " . Common::prefixTable('log_visit')
. " and " . Common::prefixTable('log_conversion') . "...");
}
flush();
@@ -246,12 +248,11 @@ for (; $start < $end; $start += $limit) {
WHERE idvisit = ?";
Db::query($sql, $bind);
}
- Piwik::log(round($start * 100 / $count) . "% done...");
+ Log::info(round($start * 100 / $count) . "% done...");
flush();
}
if ($start >= $count) {
- Piwik::log("100% done!");
- Piwik::log("");
- Piwik::log("[note] Now that you've geolocated your old visits, you need to force your reports to be re-processed. See this FAQ entry: http://piwik.org/faq/how-to/#faq_59");
-}
-
+ Log::info("100% done!");
+ Log::info("");
+ Log::info("[note] Now that you've geolocated your old visits, you need to force your reports to be re-processed. See this FAQ entry: http://piwik.org/faq/how-to/#faq_59");
+} \ No newline at end of file
diff --git a/misc/others/test_generateLotsVisitsWebsites.php b/misc/others/test_generateLotsVisitsWebsites.php
index f2a4ba94b0..77c84cdc4f 100644
--- a/misc/others/test_generateLotsVisitsWebsites.php
+++ b/misc/others/test_generateLotsVisitsWebsites.php
@@ -3,6 +3,7 @@ use Piwik\Common;
use Piwik\Config;
use Piwik\FrontController;
use Piwik\Piwik;
+use Piwik\Log;
define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../.."));
define('PIWIK_ENABLE_DISPATCH', false);
@@ -30,7 +31,8 @@ class Piwik_StressTests_CopyLogs
{
$config = Config::getInstance();
$config->log['log_only_when_debug_parameter'] = 0;
- $config->log['logger_message'] = array("logger_message" => "screen");
+ $config->log['log_writers'] = array('screen');
+ $config->log['log_level'] = 'VERBOSE';
}
function run()
@@ -117,7 +119,7 @@ class Piwik_StressTests_CopyLogs
function log($m)
{
- Piwik::log($m);
+ Log::info($m);
}
function getVisitsToday()
@@ -142,4 +144,4 @@ class Piwik_StressTests_CopyLogs
$sql = "SELECT count(*) FROM `" . Common::prefixTable('log_link_visit_action') . "` WHERE idsite >= 1 AND DATE(`server_time`) = CURRENT_DATE;";
return \Zend_Registry::get('db')->fetchOne($sql);
}
-}
+} \ No newline at end of file
diff --git a/plugins/PrivacyManager/LogDataPurger.php b/plugins/PrivacyManager/LogDataPurger.php
index 9799dc0213..9a60af5781 100755
--- a/plugins/PrivacyManager/LogDataPurger.php
+++ b/plugins/PrivacyManager/LogDataPurger.php
@@ -14,6 +14,7 @@ use Piwik\Common;
use Piwik\Date;
use Piwik\Db;
use Piwik\Piwik;
+use Piwik\Log;
/**
* Purges the log_visit, log_conversion and related tables of old visit data.
@@ -85,7 +86,7 @@ class LogDataPurger
$this->purgeUnusedLogActions();
} else {
$logMessage = get_class($this) . ": LOCK TABLES privilege not granted; skipping unused actions purge";
- Piwik::log($logMessage);
+ Log::warning($logMessage);
}
// optimize table overhead after deletion
@@ -323,5 +324,4 @@ class LogDataPurger
$settings['delete_logs_max_rows_per_query']
);
}
-}
-
+} \ No newline at end of file
diff --git a/plugins/SEO/RankChecker.php b/plugins/SEO/RankChecker.php
index 9584d4bc2a..373a2eabea 100644
--- a/plugins/SEO/RankChecker.php
+++ b/plugins/SEO/RankChecker.php
@@ -14,6 +14,7 @@ use Exception;
use Piwik\Http;
use Piwik\MetricsFormatter;
use Piwik\Piwik;
+use Piwik\Log;
/**
* The functions below are derived/adapted from GetRank.org's
@@ -190,7 +191,7 @@ class RankChecker
$majesticInfo = $this->getMajesticInfo();
return $majesticInfo['backlink_count'];
} catch (Exception $e) {
- Piwik::log($e->getMessage());
+ Log::info($e);
return 0;
}
}
@@ -206,7 +207,7 @@ class RankChecker
$majesticInfo = $this->getMajesticInfo();
return $majesticInfo['referrer_domains_count'];
} catch (Exception $e) {
- Piwik::log($e->getMessage());
+ Log::info($e);
return 0;
}
}
diff --git a/plugins/UserCountry/GeoIPAutoUpdater.php b/plugins/UserCountry/GeoIPAutoUpdater.php
index cb7deb50a7..2bd9362fea 100755
--- a/plugins/UserCountry/GeoIPAutoUpdater.php
+++ b/plugins/UserCountry/GeoIPAutoUpdater.php
@@ -12,6 +12,7 @@ namespace Piwik\Plugins\UserCountry;
use Exception;
use Piwik\Piwik;
+use Piwik\Log;
use Piwik\Common;
use Piwik\Date;
use Piwik\Http;
@@ -78,7 +79,7 @@ class GeoIPAutoUpdater
}
} catch (Exception $ex) {
// message will already be prefixed w/ 'GeoIPAutoUpdater: '
- Piwik::log($ex->getMessage());
+ Log::error($ex);
$this->performRedundantDbChecks();
throw $ex;
}
@@ -120,7 +121,7 @@ class GeoIPAutoUpdater
. "'$zippedOutputPath'! (Unknown error)");
}
- Piwik::log(sprintf("GeoIPAutoUpdater: successfully downloaded '%s'", $url));
+ Log::info("GeoIPAutoUpdater: successfully downloaded '%s'", $url);
try {
self::unzipDownloadedFile($zippedOutputPath, $unlink = true);
@@ -129,7 +130,7 @@ class GeoIPAutoUpdater
. "downloading " . "'$url': " . $ex->getMessage());
}
- Piwik::log(sprintf("GeoIPAutoUpdater: successfully updated GeoIP database '%s'", $url));
+ Log::info("GeoIPAutoUpdater: successfully updated GeoIP database '%s'", $url);
}
/**
@@ -221,8 +222,8 @@ class GeoIPAutoUpdater
) {
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
- Piwik::log("GeoIPAutoUpdater: Encountered PHP error when testing newly downloaded" .
- " GeoIP database: $errno: $errstr on line $errline of $errfile.");
+ Log::info("GeoIPAutoUpdater: Encountered PHP error when testing newly downloaded" .
+ " GeoIP database: %s: %s on line %s of %s.", $errno, $errstr, $errline, $errfile);
}
throw new Exception(Piwik_Translate('UserCountry_ThisUrlIsNotAValidGeoIPDB'));
@@ -530,8 +531,8 @@ class GeoIPAutoUpdater
self::getTestLocationCatchPhpErrors($provider);
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
- Piwik::log("GeoIPAutoUpdater: Encountered PHP error when performing redundant " .
- "tests on GeoIP $type database: $errno: $errstr on line $errline of $errfile.");
+ Log::warning("GeoIPAutoUpdater: Encountered PHP error when performing redundant tests on GeoIP "
+ . "%s database: %s: %s on line %s of %s.", $type, $errno, $errstr, $errline, $errfile);
// get the current filename for the DB and an available new one to rename it to
list($oldPath, $newPath) = $this->getOldAndNewPathsForBrokenDb($customNames[$type]);
diff --git a/plugins/UserCountry/LocationProvider/GeoIp/Php.php b/plugins/UserCountry/LocationProvider/GeoIp/Php.php
index 7bd9ba0e26..e3fd8a369a 100755
--- a/plugins/UserCountry/LocationProvider/GeoIp/Php.php
+++ b/plugins/UserCountry/LocationProvider/GeoIp/Php.php
@@ -11,6 +11,7 @@
namespace Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
use Piwik\Piwik;
+use Piwik\Log;
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp;
/**
@@ -129,7 +130,7 @@ class Php extends GeoIp
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
break;
default: // unknown database type, log warning and fallback to country edition
- Piwik::log(sprintf("Found unrecognized database type: %s", $locationGeoIp->databaseType));
+ Log::warning("Found unrecognized database type: %s", $locationGeoIp->databaseType);
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
break;
@@ -206,7 +207,7 @@ class Php extends GeoIp
if ($geoIpError) {
list($errno, $errstr, $errfile, $errline) = $geoIpError;
- Piwik::log("Got GeoIP error when testing PHP GeoIP location provider: $errfile($errline): $errstr");
+ Log::warning("Got GeoIP error when testing PHP GeoIP location provider: %s(%s): %s", $errfile, $errline, $errstr);
return Piwik_Translate('UserCountry_GeoIPIncorrectDatabaseFormat');
}
diff --git a/tests/PHPUnit/Integration/ArchiveCronTest.php b/tests/PHPUnit/Integration/ArchiveCronTest.php
index ba96ed231a..744d149ca8 100644
--- a/tests/PHPUnit/Integration/ArchiveCronTest.php
+++ b/tests/PHPUnit/Integration/ArchiveCronTest.php
@@ -124,7 +124,7 @@ class Test_Piwik_Integration_ArchiveCronTest extends IntegrationTestCase
// run the command
exec($cmd, $output, $result);
if ($result !== 0) {
- throw new Exception("log importer failed: " . implode("\n", $output) . "\n\ncommand used: $cmd");
+ throw new Exception("archive cron failed: " . implode("\n", $output) . "\n\ncommand used: $cmd");
}
return $output;
diff --git a/tests/PHPUnit/Plugins/UserCountryTest.php b/tests/PHPUnit/Plugins/UserCountryTest.php
index 4d1be73b94..033e13ee16 100644
--- a/tests/PHPUnit/Plugins/UserCountryTest.php
+++ b/tests/PHPUnit/Plugins/UserCountryTest.php
@@ -129,7 +129,7 @@ class Test_Piwik_UserCountry extends PHPUnit_Framework_Testcase
public function setUp()
{
- Piwik::$shouldLog = null;
+ // empty
}
public function tearDown()
diff --git a/tests/PHPUnit/config.ini.travis.php b/tests/PHPUnit/config.ini.travis.php
index 3c19606cc2..2c879461c4 100644
--- a/tests/PHPUnit/config.ini.travis.php
+++ b/tests/PHPUnit/config.ini.travis.php
@@ -17,4 +17,5 @@ tables_prefix = piwiktests_
;charset = utf8
[log]
-logger_message[] = file \ No newline at end of file
+log_writers[] = file
+log_level = debug \ No newline at end of file