View Javadoc

1    /*** MirkELogger.java - part of the MirkE (say murky) application for colormetric analysis emphesizing 
2     kinetics.
3     
4     Created by: Abuayyub on 25 January, 2005.
5     Last modified by: Abuayyub on 25 January, 2005.
6     
7     Copyright (c) 2004 Arizona State University - Cancer Research Institute. All rights reserved.
8     
9     MirkE is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    MirkE is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with MirkE; if not, write to the Free Software
21    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
22    */
23   
24   package> edu.asu.cri.MirkE.trace;
25   
26   import org.apache.commons.logging.Log;
27   import org.apache.commons.logging.LogFactory;
28   
29   
30   /***
31    * @author abuayyub
32    * Mirke Logger used by the MirkeAspectLogger.
33    * methods that log exception and method trace.  
34    */
35   public class MirkELogger {
36      
37       /***
38        * Logger
39        * */
40       private Log log = null;   
41           
42       public MirkELogger(){
43          
44       }
45       
46       /***
47        * log the information of the method entry joinpoint
48        * @param aClass class name
49        * @param message log message
50        * */ 
51       public void entry(String aClass,String message){
52           try{
53               log = LogFactory.getLog(Class.forName(aClass));
54           }catch(Exception e){
55               e.printStackTrace();
56           }           
57           log.debug("[ "+ message+" ]");
58       }
59       /***
60        * log the information of the method entry joinpoint
61        * @param aClass name
62        * @param message log message
63        * */ 
64       public  void exit(String aClass, String message){     
65           
66           try{  //ToDo how to log an exception thrown by the exception logger
67               //probably open a file and write the stack trace to it
68               log = LogFactory.getLog(Class.forName(aClass));
69           }catch(Exception e){
70               e.printStackTrace();
71           }      
72           
73           log.debug("[ " + message +" ]");
74       }
75     
76     /***
77      * log the information of the method entry joinpoint
78      * @param aClass class name
79      * @param message log message
80      * */ 
81     public  void error(String aClass, String message){
82         try{
83             log = LogFactory.getLog(Class.forName(aClass));
84             }catch(Exception e){
85                 e.printStackTrace();
86             }     
87         log.error("[ " + message+ "]");
88     	}
89     
90     /***
91      * log the information of the method entry joinpoint
92      * @param aClass class name
93      * @param message log message
94      * */ 
95   public void warning(String aClass,String message){
96       try{
97           log = LogFactory.getLog(Class.forName(aClass));
98           }catch(Exception e){
99               e.printStackTrace();
100          }           
101      log.debug("[ "+ message+" ]");
102   }
103  
104      /***
105       * @param aClass
106       * @return <code>true</code> if debug is enabled for the logger for <code>aClass</code> 
107       */
108      public boolean isDebug(String aClass){
109          try{
110              log = LogFactory.getLog(Class.forName(aClass));
111          }catch(Exception e) {
112              e.printStackTrace();
113          }
114          return log.isDebugEnabled();
115      }
116      
117           
118  }