• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.mms;
18 
19 import android.util.Log;
20 
21 public class LogTag {
22     public static final String TAG = "Mms";
23 
24     public static final String TRANSACTION = "Mms:transaction";
25     public static final String APP = "Mms:app";
26 
prettyArray(String[] array)27     private static String prettyArray(String[] array) {
28         if (array.length == 0) {
29             return "[]";
30         }
31 
32         StringBuilder sb = new StringBuilder("[");
33         int len = array.length-1;
34         for (int i = 0; i < len; i++) {
35             sb.append(array[i]);
36             sb.append(", ");
37         }
38         sb.append(array[len]);
39         sb.append("]");
40 
41         return sb.toString();
42     }
43 
logFormat(String format, Object... args)44     private static String logFormat(String format, Object... args) {
45         for (int i = 0; i < args.length; i++) {
46             if (args[i] instanceof String[]) {
47                 args[i] = prettyArray((String[])args[i]);
48             }
49         }
50         String s = String.format(format, args);
51         s = "[" + Thread.currentThread().getId() + "] " + s;
52         return s;
53     }
54 
debug(String format, Object... args)55     public static void debug(String format, Object... args) {
56         Log.d(TAG, logFormat(format, args));
57     }
58 
warn(String format, Object... args)59     public static void warn(String format, Object... args) {
60         Log.w(TAG, logFormat(format, args));
61     }
62 
error(String format, Object... args)63     public static void error(String format, Object... args) {
64         Log.e(TAG, logFormat(format, args));
65     }
66 }
67