1/*
2 * Copyright (C) 2008 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
17/**
18 * package-level logging flag
19 */
20
21package com.android.deskclock;
22
23import android.os.Build;
24import android.util.Log;
25
26public class LogUtils {
27
28    public final static String LOGTAG = "AlarmClock";
29    public final static boolean DEBUG = "eng".equals(Build.TYPE) || "userdebug".equals(Build.TYPE);
30
31    public static void v(String message, Object... args) {
32        if (DEBUG || Log.isLoggable(LOGTAG, Log.VERBOSE)) {
33            Log.v(LOGTAG, args == null ? message : String.format(message, args));
34        }
35    }
36
37    public static void v(String tag, String message, Object... args) {
38        if (DEBUG || Log.isLoggable(LOGTAG, Log.VERBOSE)) {
39            Log.v(LOGTAG + "/" + tag, args == null ? message : String.format(message, args));
40        }
41    }
42
43    public static void d(String message, Object... args) {
44        if (DEBUG || Log.isLoggable(LOGTAG, Log.DEBUG)) {
45            Log.d(LOGTAG, args == null ? message : String.format(message, args));
46        }
47    }
48
49    public static void d(String tag, String message, Object... args) {
50        if (DEBUG || Log.isLoggable(LOGTAG, Log.DEBUG)) {
51            Log.d(LOGTAG + "/" + tag, args == null ? message : String.format(message, args));
52        }
53    }
54
55    public static void i(String message, Object... args) {
56        if (DEBUG || Log.isLoggable(LOGTAG, Log.INFO)) {
57            Log.i(LOGTAG, args == null ? message : String.format(message, args));
58        }
59    }
60
61    public static void i(String tag, String message, Object... args) {
62        if (DEBUG || Log.isLoggable(LOGTAG, Log.INFO)) {
63            Log.i(LOGTAG + "/" + tag, args == null ? message : String.format(message, args));
64        }
65    }
66
67    public static void w(String message, Object... args) {
68        if (DEBUG || Log.isLoggable(LOGTAG, Log.WARN)) {
69            Log.w(LOGTAG, args == null ? message : String.format(message, args));
70        }
71    }
72
73    public static void w(String tag, String message, Object... args) {
74        if (DEBUG || Log.isLoggable(LOGTAG, Log.WARN)) {
75            Log.w(LOGTAG + "/" + tag, args == null ? message : String.format(message, args));
76        }
77    }
78
79    public static void e(String message, Object... args) {
80        if (DEBUG || Log.isLoggable(LOGTAG, Log.ERROR)) {
81            Log.e(LOGTAG, args == null ? message : String.format(message, args));
82        }
83    }
84
85    public static void e(String tag, String message, Object... args) {
86        if (DEBUG || Log.isLoggable(LOGTAG, Log.ERROR)) {
87            Log.e(LOGTAG + "/" + tag, args == null ? message : String.format(message, args));
88        }
89    }
90
91    public static void e(String message, Exception e) {
92        if (DEBUG || Log.isLoggable(LOGTAG, Log.ERROR)) {
93            Log.e(LOGTAG, message, e);
94        }
95    }
96
97    public static void e(String tag, String message, Exception e) {
98        if (DEBUG || Log.isLoggable(LOGTAG, Log.ERROR)) {
99            Log.e(LOGTAG + "/" + tag, message, e);
100        }
101    }
102
103    public static void wtf(String message, Object... args) {
104        if (DEBUG || Log.isLoggable(LOGTAG, Log.ASSERT)) {
105            Log.wtf(LOGTAG, args == null ? message : String.format(message, args));
106        }
107    }
108
109    public static void wtf(String tag, String message, Object... args) {
110        if (DEBUG || Log.isLoggable(LOGTAG, Log.ASSERT)) {
111            Log.wtf(LOGTAG + "/" + tag, args == null ? message : String.format(message, args));
112        }
113    }
114}
115