001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.vfs2;
018
019 import org.apache.commons.logging.Log;
020
021 /**
022 * This class is to keep the old logging behaviour (for ant-task) and to be able to
023 * correctly use commons-logging.<br>
024 * I hope i could remove it sometimes.
025 *
026 * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
027 */
028 public final class VfsLog
029 {
030 // static utility class
031 private VfsLog()
032 {
033 }
034
035 /**
036 * warning.
037 * @param vfslog The base component Logger to use.
038 * @param commonslog The class specific Logger
039 * @param message The message to log.
040 * @param t The exception, if any.
041 */
042 public static void warn(Log vfslog, Log commonslog, String message, Throwable t)
043 {
044 if (vfslog != null)
045 {
046 vfslog.warn(message, t);
047 }
048 else if (commonslog != null)
049 {
050 commonslog.warn(message, t);
051 }
052 }
053
054 /**
055 * warning.
056 * @param vfslog The base component Logger to use.
057 * @param commonslog The class specific Logger
058 * @param message The message to log.
059 */
060 public static void warn(Log vfslog, Log commonslog, String message)
061 {
062 if (vfslog != null)
063 {
064 vfslog.warn(message);
065 }
066 else if (commonslog != null)
067 {
068 commonslog.warn(message);
069 }
070 }
071
072 /**
073 * debug.
074 * @param vfslog The base component Logger to use.
075 * @param commonslog The class specific Logger
076 * @param message The message to log.
077 */
078 public static void debug(Log vfslog, Log commonslog, String message)
079 {
080 if (vfslog != null)
081 {
082 vfslog.debug(message);
083 }
084 else if (commonslog != null)
085 {
086 commonslog.debug(message);
087 }
088 }
089
090 /**
091 * debug.
092 * @param vfslog The base component Logger to use.
093 * @param commonslog The class specific Logger
094 * @param message The message to log.
095 * @param t The exception, if any.
096 */
097 public static void debug(Log vfslog, Log commonslog, String message, Throwable t)
098 {
099 if (vfslog != null)
100 {
101 vfslog.debug(message, t);
102 }
103 else if (commonslog != null)
104 {
105 commonslog.debug(message, t);
106 }
107 }
108
109 /**
110 * info.
111 * @param vfslog The base component Logger to use.
112 * @param commonslog The class specific Logger
113 * @param message The message to log.
114 * @param t The exception, if any.
115 */
116 public static void info(Log vfslog, Log commonslog, String message, Throwable t)
117 {
118 if (vfslog != null)
119 {
120 vfslog.info(message, t);
121 }
122 else if (commonslog != null)
123 {
124 commonslog.info(message, t);
125 }
126 }
127
128 /**
129 * info.
130 * @param vfslog The base component Logger to use.
131 * @param commonslog The class specific Logger
132 * @param message The message to log.
133 */
134 public static void info(Log vfslog, Log commonslog, String message)
135 {
136 if (vfslog != null)
137 {
138 vfslog.info(message);
139 }
140 else if (commonslog != null)
141 {
142 commonslog.info(message);
143 }
144 }
145
146 /**
147 * error.
148 * @param vfslog The base component Logger to use.
149 * @param commonslog The class specific Logger
150 * @param message The message to log.
151 * @param t The exception, if any.
152 */
153 public static void error(Log vfslog, Log commonslog, String message, Throwable t)
154 {
155 if (vfslog != null)
156 {
157 vfslog.error(message, t);
158 }
159 else if (commonslog != null)
160 {
161 commonslog.error(message, t);
162 }
163 }
164
165 /**
166 * error.
167 * @param vfslog The base component Logger to use.
168 * @param commonslog The class specific Logger
169 * @param message The message to log.
170 */
171 public static void error(Log vfslog, Log commonslog, String message)
172 {
173 if (vfslog != null)
174 {
175 vfslog.error(message);
176 }
177 else if (commonslog != null)
178 {
179 commonslog.error(message);
180 }
181 }
182
183 /**
184 * fatal.
185 * @param vfslog The base component Logger to use.
186 * @param commonslog The class specific Logger
187 * @param message The message to log.
188 * @param t The exception, if any.
189 */
190 public static void fatal(Log vfslog, Log commonslog, String message, Throwable t)
191 {
192 if (vfslog != null)
193 {
194 vfslog.fatal(message, t);
195 }
196 else if (commonslog != null)
197 {
198 commonslog.fatal(message, t);
199 }
200 }
201
202 /**
203 * fatal.
204 * @param vfslog The base component Logger to use.
205 * @param commonslog The class specific Logger
206 * @param message The message to log.
207 */
208 public static void fatal(Log vfslog, Log commonslog, String message)
209 {
210 if (vfslog != null)
211 {
212 vfslog.fatal(message);
213 }
214 else if (commonslog != null)
215 {
216 commonslog.fatal(message);
217 }
218 }
219 }