From a726a1f907bd60945934cbf68f031c8507a3bf95 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Mon, 1 Dec 2014 14:15:21 +1300 Subject: #6622 Logger refactoring: simplified log formatters --- core/Log.php | 50 +------------------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) (limited to 'core/Log.php') diff --git a/core/Log.php b/core/Log.php index 2892c4406d..904cdb0f83 100644 --- a/core/Log.php +++ b/core/Log.php @@ -10,8 +10,6 @@ namespace Piwik; use Piwik\Container\StaticContainer; use Piwik\Db; -use Piwik\Log\Backend\StdOutBackend; -use Piwik\Log\LoggerFactory; /** * Logging utility class. @@ -155,14 +153,6 @@ class Log extends Singleton */ private $writers = array(); - /** - * The log message format string that turns a tag name, date-time and message into - * one string to log. - * - * @var string - */ - private $logMessageFormat; - public static function getInstance() { if (self::$instance === null) { @@ -181,14 +171,12 @@ class Log extends Singleton /** * @param callable[] $writers - * @param string $logMessageFormat * @param int $logLevel * @param callable[] $processors */ - public function __construct(array $writers, $logMessageFormat, $logLevel, array $processors) + public function __construct(array $writers, $logLevel, array $processors) { $this->writers = $writers; - $this->logMessageFormat = $logMessageFormat; $this->currentLogLevel = $logLevel; $this->processors = $processors; } @@ -256,29 +244,6 @@ class Log extends Singleton self::logMessage(self::VERBOSE, $message, array_slice(func_get_args(), 1)); } - /** - * Creates log message combining logging info including a log level, tag name, - * date time, and caller-provided log message. The log message can be set through - * the `[log] string_message_format` INI config option. By default it will - * create log messages like: - * - * **LEVEL [tag:datetime] log message** - * - * @param int $level - * @param string $tag - * @param string $datetime - * @param string $message - * @return string - */ - public function formatMessage($level, $tag, $datetime, $message) - { - return str_replace( - array("%tag%", "%message%", "%datetime%", "%level%"), - array($tag, trim($message), $datetime, $this->getStringLevel($level)), - $this->logMessageFormat - ); - } - public function setLogLevel($logLevel) { $this->currentLogLevel = $logLevel; @@ -321,19 +286,6 @@ class Log extends Singleton return $level <= $this->currentLogLevel; } - private function getStringLevel($level) - { - static $levelToName = array( - self::NONE => 'NONE', - self::ERROR => 'ERROR', - self::WARN => 'WARN', - self::INFO => 'INFO', - self::DEBUG => 'DEBUG', - self::VERBOSE => 'VERBOSE' - ); - return $levelToName[$level]; - } - private function getClassNameThatIsLogging($backtrace) { foreach ($backtrace as $tracepoint) { -- cgit v1.2.3