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  package org.apache.commons.vfs;
18  
19  import org.apache.commons.logging.Log;
20  
21  /***
22   * This class is to keep the old logging behaviour (for ant-task) and to be able to
23   * correctly use commons-logging.<br>
24   * I hope i could remove it sometimes.
25   *
26   * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
27   * @version $Revision: 480428 $ $Date: 2006-11-29 07:15:24 +0100 (Mi, 29 Nov 2006) $
28   */
29  public class VfsLog
30  {
31      // static utility class
32      private VfsLog()
33      {
34      }
35  
36      /***
37       * warning
38       */
39      public static void warn(Log vfslog, Log commonslog, String message, Throwable t)
40      {
41          if (vfslog != null)
42          {
43              vfslog.warn(message, t);
44          }
45          else if (commonslog != null)
46          {
47              commonslog.warn(message, t);
48          }
49      }
50  
51      /***
52       * warning
53       */
54      public static void warn(Log vfslog, Log commonslog, String message)
55      {
56          if (vfslog != null)
57          {
58              vfslog.warn(message);
59          }
60          else if (commonslog != null)
61          {
62              commonslog.warn(message);
63          }
64      }
65  
66      /***
67       * debug
68       */
69      public static void debug(Log vfslog, Log commonslog, String message)
70      {
71          if (vfslog != null)
72          {
73              vfslog.debug(message);
74          }
75          else if (commonslog != null)
76          {
77              commonslog.debug(message);
78          }
79      }
80  
81      /***
82       * debug
83       */
84      public static void debug(Log vfslog, Log commonslog, String message, Throwable t)
85      {
86          if (vfslog != null)
87          {
88              vfslog.debug(message, t);
89          }
90          else if (commonslog != null)
91          {
92              commonslog.debug(message, t);
93          }
94      }
95  
96      /***
97       * info
98       */
99      public static void info(Log vfslog, Log commonslog, String message, Throwable t)
100     {
101         if (vfslog != null)
102         {
103             vfslog.info(message, t);
104         }
105         else if (commonslog != null)
106         {
107             commonslog.info(message, t);
108         }
109     }
110 
111     /***
112      * info
113      */
114     public static void info(Log vfslog, Log commonslog, String message)
115     {
116         if (vfslog != null)
117         {
118             vfslog.info(message);
119         }
120         else if (commonslog != null)
121         {
122             commonslog.info(message);
123         }
124     }
125 
126     /***
127      * error
128      */
129     public static void error(Log vfslog, Log commonslog, String message, Throwable t)
130     {
131         if (vfslog != null)
132         {
133             vfslog.error(message, t);
134         }
135         else if (commonslog != null)
136         {
137             commonslog.error(message, t);
138         }
139     }
140 
141     /***
142      * error
143      */
144     public static void error(Log vfslog, Log commonslog, String message)
145     {
146         if (vfslog != null)
147         {
148             vfslog.error(message);
149         }
150         else if (commonslog != null)
151         {
152             commonslog.error(message);
153         }
154     }
155 
156     /***
157      * fatal
158      */
159     public static void fatal(Log vfslog, Log commonslog, String message, Throwable t)
160     {
161         if (vfslog != null)
162         {
163             vfslog.fatal(message, t);
164         }
165         else if (commonslog != null)
166         {
167             commonslog.fatal(message, t);
168         }
169     }
170 
171     /***
172      * fatal
173      */
174     public static void fatal(Log vfslog, Log commonslog, String message)
175     {
176         if (vfslog != null)
177         {
178             vfslog.fatal(message);
179         }
180         else if (commonslog != null)
181         {
182             commonslog.fatal(message);
183         }
184     }
185 }