function __construct($name)
 {
     /**
      * switch off/on error reporting to prevent messages like
      * "ERR (3): Warning: include(Praxigento\Log\Logger.php): failed to open stream: No such file or directory"
      * in case of Praxigento_Log module is not used.
      */
     $level = error_reporting(0);
     self::$_isLog4phpUsed = class_exists('Praxigento_Log_Logger', true);
     error_reporting($level);
     if (self::$_isLog4phpUsed) {
         $this->_loggerLog4php = Praxigento_Log_Logger::getLogger($name);
     } else {
         $this->_name = is_object($name) ? get_class($name) : (string) $name;
     }
 }
 public function test_levels()
 {
     $currentState = Mage::getStoreConfig('dev/log/active');
     /* switch logging on */
     Praxigento_Log_Logger::resetConfiguration();
     Mage::app()->getStore()->setConfig('dev/log/active', 1);
     $log = Praxigento_Log_Logger::getLogger(__CLASS__);
     $log->trace('trace level message');
     $log->debug('debug level message');
     $log->info('info level message');
     $log->warn('warn level message');
     $log->error('error level message');
     $log->fatal('fatal level message');
     /* restore logging */
     Mage::app()->getStore()->setConfig('dev/log/active', $currentState);
 }
Beispiel #3
0
 /**
  * Analyze Magento configuration and load Log4php configuration file.
  */
 private static function initMageLogger()
 {
     $dir = Mage::getBaseDir('base');
     $isActive = (string) Mage::getStoreConfig('dev/log/active');
     $isActive = filter_var($isActive, FILTER_VALIDATE_BOOLEAN);
     if ($isActive) {
         /* use configuration file*/
         $cfg = (string) Mage::getStoreConfig('dev/log/prxgt_log4php_config_file');
         $file = $dir . DS . $cfg;
         Praxigento_Log_Logger::configure($file);
     } else {
         /* disable Log4php output */
         $options = array('threshold' => 'off');
         Praxigento_Log_Logger::configure($options);
     }
     Praxigento_Log_Logger::$_isInitialized = true;
 }