From 38c12104b3a45c362239749041506d1222b58e72 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Wed, 29 Mar 2017 08:28:24 +0000 Subject: [PATCH] N.740 Error when attempting to disable the logs. Took the opportunity to refactor, relying on late static bindings (requires PHP 5.3). The refactoring avoided the fix to be duplicated in three places. SVN:trunk[4628] --- core/log.class.inc.php | 87 +++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 57 deletions(-) diff --git a/core/log.class.inc.php b/core/log.class.inc.php index 736d7861a1..1902bad563 100644 --- a/core/log.class.inc.php +++ b/core/log.class.inc.php @@ -1,5 +1,5 @@ Error($sText); + if (static::$m_oFileLog) + { + static::$m_oFileLog->Error($sText); + } } public static function Warning($sText) { - self::$m_oFileLog->Warning($sText); + if (static::$m_oFileLog) + { + static::$m_oFileLog->Warning($sText); + } } public static function Info($sText) { - self::$m_oFileLog->Info($sText); + if (static::$m_oFileLog) + { + static::$m_oFileLog->Info($sText); + } } public static function Ok($sText) { - self::$m_oFileLog->Ok($sText); + if (static::$m_oFileLog) + { + static::$m_oFileLog->Ok($sText); + } } } -class IssueLog +class SetupLog extends LogAPI { - protected static $m_oFileLog; - - public static function Enable($sTargetFile) - { - self::$m_oFileLog = new FileLog($sTargetFile); - } - public static function Error($sText) - { - self::$m_oFileLog->Error($sText); - } - public static function Warning($sText) - { - self::$m_oFileLog->Warning($sText); - } - public static function Info($sText) - { - self::$m_oFileLog->Info($sText); - } - public static function Ok($sText) - { - self::$m_oFileLog->Ok($sText); - } + protected static $m_oFileLog = null; } -class ToolsLog +class IssueLog extends LogAPI { - protected static $m_oFileLog; - - public static function Enable($sTargetFile) - { - self::$m_oFileLog = new FileLog($sTargetFile); - } - public static function Error($sText) - { - self::$m_oFileLog->Error($sText); - } - public static function Warning($sText) - { - self::$m_oFileLog->Warning($sText); - } - public static function Info($sText) - { - self::$m_oFileLog->Info($sText); - } - public static function Ok($sText) - { - self::$m_oFileLog->Ok($sText); - } + protected static $m_oFileLog = null; +} + +class ToolsLog extends LogAPI +{ + protected static $m_oFileLog = null; } -?>