View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.logging.impl;
19  
20  import java.io.Serializable;
21  
22  import org.apache.commons.logging.Log;
23  
24  /**
25   * Trivial implementation of Log that throws away all messages. No configurable system properties are supported.
26   */
27  public class NoOpLog implements Log, Serializable {
28  
29      /** Serializable version identifier. */
30      private static final long serialVersionUID = 561423906191706148L;
31  
32      /** Convenience constructor */
33      public NoOpLog() {
34          // no-op
35      }
36  
37      /**
38       * Base constructor
39       *
40       * @param ignoredName unused.
41       */
42      public NoOpLog(final String ignoredName) {
43          // no-op
44      }
45  
46      /** Do nothing */
47      @Override
48      public void debug(final Object message) {
49          // no-op
50      }
51  
52      /** Do nothing */
53      @Override
54      public void debug(final Object message, final Throwable t) {
55          // no-op
56      }
57  
58      /** Do nothing */
59      @Override
60      public void error(final Object message) {
61          // no-op
62      }
63  
64      /** Do nothing */
65      @Override
66      public void error(final Object message, final Throwable t) {
67          // no-op
68      }
69  
70      /** Do nothing */
71      @Override
72      public void fatal(final Object message) {
73          // no-op
74      }
75  
76      /** Do nothing */
77      @Override
78      public void fatal(final Object message, final Throwable t) {
79          // no-op
80      }
81  
82      /** Do nothing */
83      @Override
84      public void info(final Object message) {
85          // no-op
86      }
87  
88      /** Do nothing */
89      @Override
90      public void info(final Object message, final Throwable t) {
91          // no-op
92      }
93  
94      /**
95       * Debug is never enabled.
96       *
97       * @return false
98       */
99      @Override
100     public final boolean isDebugEnabled() {
101         return false;
102     }
103 
104     /**
105      * Error is never enabled.
106      *
107      * @return false
108      */
109     @Override
110     public final boolean isErrorEnabled() {
111         return false;
112     }
113 
114     /**
115      * Fatal is never enabled.
116      *
117      * @return false
118      */
119     @Override
120     public final boolean isFatalEnabled() {
121         return false;
122     }
123 
124     /**
125      * Info is never enabled.
126      *
127      * @return false
128      */
129     @Override
130     public final boolean isInfoEnabled() {
131         return false;
132     }
133 
134     /**
135      * Trace is never enabled.
136      *
137      * @return false
138      */
139     @Override
140     public final boolean isTraceEnabled() {
141         return false;
142     }
143 
144     /**
145      * Warn is never enabled.
146      *
147      * @return false
148      */
149     @Override
150     public final boolean isWarnEnabled() {
151         return false;
152     }
153 
154     /** Do nothing */
155     @Override
156     public void trace(final Object message) {
157         // no-op
158     }
159 
160     /** Do nothing */
161     @Override
162     public void trace(final Object message, final Throwable t) {
163         // no-op
164     }
165 
166     /** Do nothing */
167     @Override
168     public void warn(final Object message) {
169         // no-op
170     }
171 
172     /** Do nothing */
173     @Override
174     public void warn(final Object message, final Throwable t) {
175         // no-op
176     }
177 }