From ddfcd645c7e76e41be029ce119fe6c70029042e2 Mon Sep 17 00:00:00 2001 From: mattpiwik <matthieu.aubry@gmail.com> Date: Fri, 15 Apr 2011 06:28:56 +0000 Subject: [PATCH] Adding two new parameters: ; if set to 1, only requests done in CLI mode (eg. the archive.sh cron run) will be logged log_only_when_cli = 0 ; if set to 1, only requests with "&debug" parameter will be logged log_only_when_debug_parameter = 0 this will make lot easier to enable debug and not mess up everything (eg. on the demo, or if piwik is heavily used by other concurrent users or via the API) git-svn-id: http://dev.piwik.org/svn/trunk@4472 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- config/global.ini.php | 10 +++++++++- core/Log.php | 5 ----- core/Piwik.php | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/config/global.ini.php b/config/global.ini.php index 910423ef34..d35a627939 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] logger_message[] = "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 @@ -342,6 +342,14 @@ encryption = ; SMTP transport-layer encryption, either 'ssl', 'tls', or emp logger_error[] = screen logger_exception[] = screen +; if set to 1, only requests done in CLI mode (eg. the archive.sh cron run) will be logged +; NOTE: log_only_when_debug_parameter will also be checked for +log_only_when_cli = 0 + +; if set to 1, only requests with "&debug" parameter will be logged +; NOTE: log_only_when_cli will also be checked for +log_only_when_debug_parameter = 0 + ; if configured to log in files, log files will be created in this path ; eg. if the value is tmp/logs files will be created in /path/to/piwik/tmp/logs/ logger_file_path = tmp/logs diff --git a/core/Log.php b/core/Log.php index 008bdd37d6..6d198a4766 100644 --- a/core/Log.php +++ b/core/Log.php @@ -49,11 +49,6 @@ abstract class Piwik_Log extends Zend_Log $this->logToDatabaseColumnMapping = $logToDatabaseColumnMapping; } - static public function dump($var) - { - Zend_Registry::get('logger_message')->logEvent(var_export($var, true)); - } - function addWriteToFile() { Piwik_Common::mkdir(dirname($this->logToFileFilename)); diff --git a/core/Piwik.php b/core/Piwik.php index 7637d481cd..82cf223ad1 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -892,7 +892,20 @@ class Piwik */ static public function log($message = '') { - Zend_Registry::get('logger_message')->logEvent($message); + static $shouldLog = null; + if(is_null($shouldLog)) + { + $shouldLog = (Piwik_Common::isPhpCliMode() + || Zend_Registry::get('config')->log->log_only_when_cli == 0) + && + ( Zend_Registry::get('config')->log->log_only_when_debug_parameter == 0 + || isset($_REQUEST['debug'])) + ; + } + if($shouldLog) + { + Zend_Registry::get('logger_message')->logEvent($message); + } } /** -- GitLab