View Javadoc

1   /*
2    * Copyright 2003,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /* 
17  
18   */
19  
20  package org.apache.pluto.portalImpl.services.log;
21  
22  import org.apache.pluto.portalImpl.services.ServiceManager;
23  import org.apache.pluto.services.log.Logger;
24  
25  /***
26   ** This is the static accessor for the <code>Logger</code>.
27   ** All log messages logged using this classes static log
28   ** methods log to the org.apache.pluto.portalImpl category.
29   **
30   ** @see   org.apache.pluto.services.log.Logger
31   **/
32  
33  public class Log
34  {
35  
36      private static Logger log =
37          getService().getLogger("org.apache.pluto.portalImpl");
38  
39      public static boolean isDebugEnabled() {
40          return log.isDebugEnabled();
41      }
42  
43      public static boolean isInfoEnabled() {
44          return log.isInfoEnabled();
45      }
46  
47      public static boolean isWarnEnabled() {
48          return log.isWarnEnabled();
49      }
50  
51      public static boolean isErrorEnabled() {
52          return log.isErrorEnabled();
53      }
54  
55      public static void debug(String aMessage) {
56          log.debug(aMessage);
57      }
58  
59      public static void debug(String aMessage, Throwable aThrowable) {
60          log.debug(aMessage, aThrowable);
61      }
62  
63      public static void info(String aMessage) {
64          log.info(aMessage);
65      }
66  
67      public static void warn(String aMessage) {
68          log.warn(aMessage);
69      }
70  
71      public static void error(String aMessage) {
72          log.error(aMessage);
73      }
74  
75      public static void error(String aMessage, Throwable aThrowable) {
76          log.error(aMessage, aThrowable);
77      }
78  
79      public static void error(Throwable aThrowable) {
80          log.error(aThrowable);
81      }
82  
83      /***
84       *  Returns the LogService which has been registered
85       *  with the ServiceManager. If one does not yet exist,
86       *  the StandardOutLogService (LogServiceImpl) is
87       *  and returned.  This must take place since the
88       *  Deployer (which does not register services) requires
89       *  a valid log.
90       *
91       * @return the {@link LogService} used for static logging.
92       */
93      public static LogService getService() {
94          LogService ls = (LogService)
95                  ServiceManager.getService(LogService.class);
96          if(ls==null)
97              ls = StandardOutLogService.getInstance();
98          return ls;
99      }
100 
101 }