View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF 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.apache.creadur.whisker.cli;
20  
21  import org.apache.commons.logging.Log;
22  
23  /**
24   * Logs important messages to system err.
25   */
26  public final class SystemLog implements Log {
27  
28      /**
29       * Ignored.
30       * @param message possibly null
31       * @see org.apache.commons.logging.Log#debug(java.lang.Object)
32       */
33      public void debug(final Object message) { }
34  
35      /**
36       * Ignored.
37       * @param message possibly null
38       * @param t possibly null
39       * @see Log#debug(java.lang.Object, java.lang.Throwable)
40       */
41      public void debug(final Object message, final Throwable t) { }
42  
43      /**
44       * Logs to stderr.
45       * @param message possibly null
46       * @see org.apache.commons.logging.Log#error(java.lang.Object)
47       */
48      public void error(final Object message) {
49          err(message);
50      }
51  
52      /**
53       * Logs to stderr.
54       * @param message not null
55       */
56      private void err(final Object message) {
57          System.err.println(message);
58      }
59  
60      /**
61       * Logs to stderr.
62       * @param message possibly null
63       * @param t possibly null
64       * @see Log#error(java.lang.Object, java.lang.Throwable)
65       */
66      public void error(final Object message, final Throwable t) {
67          err(message, t);
68      }
69  
70      /**
71       * Logs to stderr.
72       * @param message possibly null
73       * @param t possibly null
74       */
75      private void err(final Object message, final Throwable t) {
76          err(message);
77          t.printStackTrace();
78      }
79  
80      /**
81       * Logs to stderr.
82       * @param message possibly null
83       * @see org.apache.commons.logging.Log#fatal(java.lang.Object)
84       */
85      public void fatal(final Object message) {
86          err(message);
87      }
88  
89      /**
90       * Logs to stderr.
91       * @param message possibly null
92       * @param t possibly null
93       * @see Log#fatal(java.lang.Object, java.lang.Throwable)
94       */
95      public void fatal(final Object message, final Throwable t) {
96          err(message, t);
97      }
98  
99      /**
100      * Ignored.
101      * @param message possibly null
102      * @see Log#info(java.lang.Object)
103      */
104     public void info(final Object message) {
105     }
106 
107     /**
108      * Ignored.
109      * @param message possibly null
110      * @param t possibly null
111      * @see #info(java.lang.Object, java.lang.Throwable)
112      */
113     public void info(final Object message, final Throwable t) {
114     }
115 
116     /**
117      * Disabled.
118      * @return false
119      * @see org.apache.commons.logging.Log#isDebugEnabled()
120      */
121     public boolean isDebugEnabled() {
122         return false;
123     }
124 
125     /**
126      * Enabled.
127      * @return true
128      * @see org.apache.commons.logging.Log#isErrorEnabled()
129      */
130     public boolean isErrorEnabled() {
131         return true;
132     }
133 
134     /**
135      * Enabled.
136      * @return true
137      * @see org.apache.commons.logging.Log#isFatalEnabled()
138      */
139     public boolean isFatalEnabled() {
140         return true;
141     }
142 
143     /**
144      * Disabled.
145      * @return false
146      * @see org.apache.commons.logging.Log#isInfoEnabled()
147      */
148     public boolean isInfoEnabled() {
149         return false;
150     }
151 
152     /**
153      * Disabled.
154      * @return false
155      * @see org.apache.commons.logging.Log#isTraceEnabled()
156      */
157     public boolean isTraceEnabled() {
158         return false;
159     }
160 
161     /**
162      * Disabled.
163      * @return false
164      * @see org.apache.commons.logging.Log#isWarnEnabled()
165      */
166     public boolean isWarnEnabled() {
167         return false;
168     }
169 
170     /**
171      * Ignored.
172      * @param message possibly null
173      * @see org.apache.commons.logging.Log#trace(java.lang.Object)
174      */
175     public void trace(final Object message) {
176     }
177 
178     /**
179      * Ignored.
180      * @param message possibly null
181      * @param t possibly null
182      * @see Log#trace(java.lang.Object, java.lang.Throwable)
183      */
184     public void trace(final Object message, final Throwable t) {
185     }
186 
187     /**
188      * Ignored.
189      * @param message possibly null
190      * @see org.apache.commons.logging.Log#warn(java.lang.Object)
191      */
192     public void warn(final Object message) {
193     }
194 
195     /**
196      * Ignored.
197      * @param message possibly null
198      * @param t possibly null
199      * @see Log#warn(java.lang.Object, java.lang.Throwable)
200      */
201     public void warn(final Object message, final Throwable t) {
202     }
203 }