Coverage Report - pt.digitalis.dif.utils.logging.DIFLogAspect
 
Classes in this File Line Coverage Branch Coverage Complexity
DIFLogAspect
0%
0/14
0%
0/6
0
 
 1  
 /**
 2  
  * - Digitalis Internal Framework v2.0 - (C) 2007, Digitalis Informatica.
 3  
  * Distribuicao e Gestao de Informatica, Lda. Estrada de Paco de Arcos num.9 -
 4  
  * Piso -1 2780-666 Paco de Arcos Telefone: (351) 21 4408990 Fax: (351) 21
 5  
  * 4408999 http://www.digitalis.pt
 6  
  */
 7  
 package pt.digitalis.dif.utils.logging;
 8  
 
 9  
 import pt.digitalis.dif.startup.DIFStartupConfiguration;
 10  
 import pt.digitalis.log.ILogWrapper;
 11  
 import pt.digitalis.log.LogLevel;
 12  
 import pt.digitalis.log.Logger;
 13  
 
 14  
 /**
 15  
  * This is the framework's base logging aspect. It defines the logging appliance used as a protected member that can be
 16  
  * initialized on each sub-aspect constructor, an abstract pointcut - logPoints() - and an abstract logging method that
 17  
  * should be implemented by the sub-aspects. Access to the logger should be done through the supplied inspector. Logging
 18  
  * of all the Exceptions thrown by the framework or its client applications is also done by this aspect. Exception
 19  
  * logging is a top-level concern so it should be on the base aspect. This aspect also supplies some common pointcuts to
 20  
  * its children. These include capturing all methods and constructors execution and the exclusion of the logging
 21  
  * appliances (such as this aspects and its children as well as the Logger class and its children).
 22  
  * 
 23  
  * @author Rodrigo Gonçalves <a href="mailto:rgoncalves@digitalis.pt">rgoncalves@digitalis.pt</a>
 24  
  * @created 2007/05/22
 25  
  */
 26  
 
 27  0
 public abstract aspect DIFLogAspect {
 28  
 
 29  
     /* --- Members --- */
 30  
 
 31  
     /** The logger instance */
 32  
     static private ILogWrapper logger;
 33  
 
 34  
     /* --- General pointcuts --- */
 35  
 
 36  
     /** Excluding all development aspects. */
 37  0
     protected pointcut excludeAllDev() : ! within(pt.digitalis.dif.utils.development.*);
 38  
 
 39  
     /** Excluding all startup classes. */
 40  0
     protected pointcut excludeAllStartup() : ! within(pt.digitalis.dif.startup.DIFStartupConfiguration);
 41  
 
 42  
     /**
 43  
      * This pointcut excludes all the logging appliances such as this aspect and all its children as well as the
 44  
      * Logger class and any eventual children it will might to have.
 45  
      */
 46  
     protected pointcut excludeLoggingAppliances() : ! within(DIFLogAspect+) && ! within(ILogWrapper+) &&
 47  0
         excludeAllDev() && excludeAllStartup();
 48  
 
 49  
     /**
 50  
      * Captures the execution of all methods that are not part of the aspect or the Logger class.
 51  
      */
 52  0
     protected pointcut allMethods() : execution(* pt.digitalis.dif.*..*(..)) && excludeLoggingAppliances();
 53  
 
 54  
     /**
 55  
      * Captures the execution of all constructors that are not part of the aspect or the Logger class.
 56  
      */
 57  0
     protected pointcut allConstructors() : execution(pt.digitalis.dif.*..*.new(..)) && excludeLoggingAppliances();
 58  
 
 59  
     /* --- Methods --- */
 60  
 
 61  
     /**
 62  
      * Inspector for the defined logger object.
 63  
      * 
 64  
      * @return the active logger instance 
 65  
      */
 66  
     static protected ILogWrapper getLogger() {
 67  
 
 68  
         // Lazy loading
 69  0
         if (logger == null) {
 70  0
             LogLevel level = null;
 71  
             
 72  
             // Try to get log level from DiF configurations
 73  
             try {
 74  0
                 level = DIFStartupConfiguration.getLogLevel();
 75  0
             } catch (Exception e) {
 76  
                 // Catch RTEs such as NPEs and do nothing. The code below will make the logging proceed in a transparent and convenient way.
 77  
             }
 78  
             
 79  
             // If level could not be fetched before, set it to WARN
 80  0
             if(level == null)
 81  0
                 level = LogLevel.WARN;
 82  
             
 83  
             // Initialize logger with the appropriate level.
 84  0
             logger = Logger.getLogger("DIF Core", level);
 85  
         }
 86  
 
 87  
         // Return the active logger instance
 88  0
         return logger;
 89  
     }
 90  
 }