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:
authorMatthieu Napoli <matthieu@mnapoli.fr>2014-12-01 02:17:46 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2014-12-01 02:17:46 +0300
commit1d5aedc49ab2e5d07c10e600fcd5a12a1f9ce378 (patch)
tree51dc3484a86a9d4a1a7aac2b5a2929153425dd19 /core/Log.php
parent528d5dcfe266e4b18f87b9fb51cfcb8e7782f8cc (diff)
#6622 Logger refactoring: quick code simplification
Diffstat (limited to 'core/Log.php')
-rw-r--r--core/Log.php45
1 files changed, 28 insertions, 17 deletions
diff --git a/core/Log.php b/core/Log.php
index 54844f7dbb..52123d3593 100644
--- a/core/Log.php
+++ b/core/Log.php
@@ -294,25 +294,13 @@ class Log extends Singleton
return;
}
- $datetime = date("Y-m-d H:i:s");
-
foreach ($this->processors as $processor) {
$message = $processor($message, $sprintfParams, $level);
}
- if (version_compare(phpversion(), '5.3.6', '>=')) {
- $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
- } else {
- $backtrace = debug_backtrace();
- }
- $tag = Plugin::getPluginNameFromBacktrace($backtrace);
-
- // if we can't determine the plugin, use the name of the calling class
- if ($tag == false) {
- $tag = $this->getClassNameThatIsLogging($backtrace);
- }
+ $tag = $this->getLoggingClassName();
- $this->writeMessage($level, $tag, $datetime, $message);
+ $this->writeMessage($level, $tag, date("Y-m-d H:i:s"), $message);
}
private function writeMessage($level, $tag, $datetime, $message)
@@ -359,9 +347,9 @@ class Log extends Singleton
{
foreach ($backtrace as $tracepoint) {
if (isset($tracepoint['class'])
- && $tracepoint['class'] != "Piwik\\Log"
- && $tracepoint['class'] != "Piwik\\Piwik"
- && $tracepoint['class'] != "Piwik\\CronArchive"
+ && $tracepoint['class'] != 'Piwik\Log'
+ && $tracepoint['class'] != 'Piwik\Piwik'
+ && $tracepoint['class'] != 'Piwik\CronArchive'
) {
return $tracepoint['class'];
}
@@ -381,4 +369,27 @@ class Log extends Singleton
$fe = fopen('php://stderr', 'w');
fwrite($fe, $message);
}
+
+ /**
+ * Returns the name of the plugin/class that triggered the log.
+ *
+ * @return string
+ */
+ private function getLoggingClassName()
+ {
+ if (version_compare(phpversion(), '5.3.6', '>=')) {
+ $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
+ } else {
+ $backtrace = debug_backtrace();
+ }
+
+ $tag = Plugin::getPluginNameFromBacktrace($backtrace);
+
+ // if we can't determine the plugin, use the name of the calling class
+ if ($tag == false) {
+ $tag = $this->getClassNameThatIsLogging($backtrace);
+ return $tag;
+ }
+ return $tag;
+ }
}