Ejemplo n.º 1
0
 public static function &getInstance()
 {
     if (self::$_instance == null) {
         self::$_instance = new __LogManager();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 /**
  * Gets the logger associated to current context
  *
  * @return __Logger
  */
 public function &getLogger($appender = null)
 {
     return __LogManager::getInstance()->getLogger($this->_context_id, $appender);
 }
Ejemplo n.º 3
0
 public function logException(Exception $exception)
 {
     if (class_exists('__CurrentContext') && __CurrentContext::getInstance() != null) {
         $lion_runtime_directives = __Lion::getInstance()->getRuntimeDirectives();
         //log exception just in case the runtime directive is enabled
         if ($lion_runtime_directives->hasDirective('LOG_EXCEPTIONS') && $lion_runtime_directives->getDirective('LOG_EXCEPTIONS')) {
             if ($exception instanceof __LionException) {
                 $exception_desc = $exception->getLocalizedMessage(__CurrentContext::getInstance()->getPropertyContent('DEFAULT_LANG_ISO_CODE'));
             } else {
                 $exception_desc = $exception->getMessage();
             }
             $log_message = $exception_desc;
             //log extended info associated to the exception if the runtime directive is enabled:
             if ($lion_runtime_directives->hasDirective('LOG_DEBUG_INFO') && $lion_runtime_directives->getDirective('LOG_DEBUG_INFO')) {
                 $log_message .= "\n<exception>";
                 $log_message .= "\n    <description><![CDATA[" . $exception_desc . "\n]]></description>";
                 $request = __FrontController::getInstance()->getRequest();
                 $log_message .= "\n    <request><![CDATA[\n" . print_r($request, true) . "\n]]></request>";
                 $log_message .= "\n    <server><![CDATA[\n" . print_r($_SERVER, true) . "\n]]></server>";
                 $log_message .= "\n    <trace><![CDATA[\n" . $exception->getTraceAsString() . "\n]]></trace>";
                 $log_message .= "\n</exception>";
             }
             if ($exception->getCode() != 55601 && $exception->getCode() != 78010) {
                 __LogManager::getInstance()->getLogger('error')->error($log_message);
             }
         }
     }
 }