1/* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package org.apache.james.mime4j; 18 19import com.android.email.Email; 20 21/** 22 * Empty stub for the apache logging library. 23 */ 24public class Log { 25 public Log(Class mClazz) { 26 } 27 28 public boolean isDebugEnabled() { 29 return Email.LOGD; 30 } 31 32 public boolean isErrorEnabled() { 33 return true; 34 } 35 36 public boolean isFatalEnabled() { 37 return true; 38 } 39 40 public boolean isInfoEnabled() { 41 return Email.LOGD; 42 } 43 44 public boolean isTraceEnabled() { 45 return Email.LOGD; 46 } 47 48 public boolean isWarnEnabled() { 49 return true; 50 } 51 52 public void trace(Object message) { 53 if (!isTraceEnabled()) return; 54 android.util.Log.v(Email.LOG_TAG, toString(message, null)); 55 } 56 57 public void trace(Object message, Throwable t) { 58 if (!isTraceEnabled()) return; 59 android.util.Log.v(Email.LOG_TAG, toString(message, t)); 60 } 61 62 public void debug(Object message) { 63 if (!isDebugEnabled()) return; 64 android.util.Log.d(Email.LOG_TAG, toString(message, null)); 65 } 66 67 public void debug(Object message, Throwable t) { 68 if (!isDebugEnabled()) return; 69 android.util.Log.d(Email.LOG_TAG, toString(message, t)); 70 } 71 72 public void info(Object message) { 73 if (!isInfoEnabled()) return; 74 android.util.Log.i(Email.LOG_TAG, toString(message, null)); 75 } 76 77 public void info(Object message, Throwable t) { 78 if (!isInfoEnabled()) return; 79 android.util.Log.i(Email.LOG_TAG, toString(message, t)); 80 } 81 82 public void warn(Object message) { 83 android.util.Log.w(Email.LOG_TAG, toString(message, null)); 84 } 85 86 public void warn(Object message, Throwable t) { 87 android.util.Log.w(Email.LOG_TAG, toString(message, t)); 88 } 89 90 public void error(Object message) { 91 android.util.Log.e(Email.LOG_TAG, toString(message, null)); 92 } 93 94 public void error(Object message, Throwable t) { 95 android.util.Log.e(Email.LOG_TAG, toString(message, t)); 96 } 97 98 public void fatal(Object message) { 99 android.util.Log.e(Email.LOG_TAG, toString(message, null)); 100 } 101 102 public void fatal(Object message, Throwable t) { 103 android.util.Log.e(Email.LOG_TAG, toString(message, t)); 104 } 105 106 private static String toString(Object o, Throwable t) { 107 String m = (o == null) ? "(null)" : o.toString(); 108 if (t == null) { 109 return m; 110 } else { 111 return m + " " + t.getMessage(); 112 } 113 } 114} 115