View Javadoc

1   /**
2    * Licensed to jclouds, Inc. (jclouds) under one or more
3    * contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  jclouds licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.jclouds.logging;
20  
21  import com.google.common.base.Throwables;
22  
23  /**
24   * <tt>Logger</tt> that doesn't do anything.
25   * <p />
26   * Useful to get baseline performance unaffected by logging.
27   * 
28   * @author Adrian Cole
29   * 
30   */
31  public class NullLogger implements Logger {
32  
33     public void debug(String message, Object... args) {
34  
35     }
36  
37     public void error(String message, Object... args) {
38        System.err.printf(message + "%n", args);
39     }
40  
41     public void error(Throwable throwable, String message, Object... args) {
42        System.err.printf(message, args);
43        System.err.printf("%n%s", Throwables.getStackTraceAsString(throwable));
44     }
45  
46     public String getCategory() {
47  
48        return null;
49     }
50  
51     public void info(String message, Object... args) {
52  
53     }
54  
55     public boolean isDebugEnabled() {
56  
57        return false;
58     }
59  
60     public boolean isErrorEnabled() {
61  
62        return true;
63     }
64  
65     public boolean isInfoEnabled() {
66  
67        return false;
68     }
69  
70     public boolean isTraceEnabled() {
71  
72        return false;
73     }
74  
75     public boolean isWarnEnabled() {
76  
77        return false;
78     }
79  
80     public void trace(String message, Object... args) {
81  
82     }
83  
84     public void warn(String message, Object... args) {
85  
86     }
87  
88     public void warn(Throwable throwable, String message, Object... args) {
89  
90     }
91  }