diff options
| author | Joe Onorato <joeo@android.com> | 2010-02-26 18:07:01 -0800 |
|---|---|---|
| committer | Joe Onorato <joeo@android.com> | 2010-03-01 09:07:37 -0800 |
| commit | 00bb93823d082c31d757bd7b75a8615afbd2c1a5 (patch) | |
| tree | ff025fdda17321fda2bc056a84e0011cb27df84e /core/java/android | |
| parent | 7c02ef117e6720ca2c24fab6523e9c4bd665e26c (diff) | |
Add new Slog class.
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/util/Log.java | 35 | ||||
| -rw-r--r-- | core/java/android/util/Slog.java | 85 |
2 files changed, 107 insertions, 13 deletions
diff --git a/core/java/android/util/Log.java b/core/java/android/util/Log.java index 75b1b90c3ac9..354d21f54627 100644 --- a/core/java/android/util/Log.java +++ b/core/java/android/util/Log.java @@ -98,7 +98,7 @@ public final class Log { * @param msg The message you would like logged. */ public static int v(String tag, String msg) { - return println(VERBOSE, tag, msg); + return println_native(LOG_ID_MAIN, VERBOSE, tag, msg); } /** @@ -109,7 +109,7 @@ public final class Log { * @param tr An exception to log */ public static int v(String tag, String msg, Throwable tr) { - return println(VERBOSE, tag, msg + '\n' + getStackTraceString(tr)); + return println_native(LOG_ID_MAIN, VERBOSE, tag, msg + '\n' + getStackTraceString(tr)); } /** @@ -119,7 +119,7 @@ public final class Log { * @param msg The message you would like logged. */ public static int d(String tag, String msg) { - return println(DEBUG, tag, msg); + return println_native(LOG_ID_MAIN, DEBUG, tag, msg); } /** @@ -130,7 +130,7 @@ public final class Log { * @param tr An exception to log */ public static int d(String tag, String msg, Throwable tr) { - return println(DEBUG, tag, msg + '\n' + getStackTraceString(tr)); + return println_native(LOG_ID_MAIN, DEBUG, tag, msg + '\n' + getStackTraceString(tr)); } /** @@ -140,7 +140,7 @@ public final class Log { * @param msg The message you would like logged. */ public static int i(String tag, String msg) { - return println(INFO, tag, msg); + return println_native(LOG_ID_MAIN, INFO, tag, msg); } /** @@ -151,7 +151,7 @@ public final class Log { * @param tr An exception to log */ public static int i(String tag, String msg, Throwable tr) { - return println(INFO, tag, msg + '\n' + getStackTraceString(tr)); + return println_native(LOG_ID_MAIN, INFO, tag, msg + '\n' + getStackTraceString(tr)); } /** @@ -161,7 +161,7 @@ public final class Log { * @param msg The message you would like logged. */ public static int w(String tag, String msg) { - return println(WARN, tag, msg); + return println_native(LOG_ID_MAIN, WARN, tag, msg); } /** @@ -172,7 +172,7 @@ public final class Log { * @param tr An exception to log */ public static int w(String tag, String msg, Throwable tr) { - return println(WARN, tag, msg + '\n' + getStackTraceString(tr)); + return println_native(LOG_ID_MAIN, WARN, tag, msg + '\n' + getStackTraceString(tr)); } /** @@ -202,7 +202,7 @@ public final class Log { * @param tr An exception to log */ public static int w(String tag, Throwable tr) { - return println(WARN, tag, getStackTraceString(tr)); + return println_native(LOG_ID_MAIN, WARN, tag, getStackTraceString(tr)); } /** @@ -212,7 +212,7 @@ public final class Log { * @param msg The message you would like logged. */ public static int e(String tag, String msg) { - return println(ERROR, tag, msg); + return println_native(LOG_ID_MAIN, ERROR, tag, msg); } /** @@ -223,7 +223,7 @@ public final class Log { * @param tr An exception to log */ public static int e(String tag, String msg, Throwable tr) { - return println(ERROR, tag, msg + '\n' + getStackTraceString(tr)); + return println_native(LOG_ID_MAIN, ERROR, tag, msg + '\n' + getStackTraceString(tr)); } /** @@ -258,7 +258,7 @@ public final class Log { */ public static int wtf(String tag, String msg, Throwable tr) { tr = new TerribleFailure(msg, tr); - int bytes = println(ASSERT, tag, getStackTraceString(tr)); + int bytes = println_native(LOG_ID_MAIN, ASSERT, tag, getStackTraceString(tr)); RuntimeInit.wtf(tag, tr); return bytes; } @@ -285,5 +285,14 @@ public final class Log { * @param msg The message you would like logged. * @return The number of bytes written. */ - public static native int println(int priority, String tag, String msg); + public static int println(int priority, String tag, String msg) { + return println_native(LOG_ID_MAIN, priority, tag, msg); + } + + static final int LOG_ID_MAIN = 0; + static final int LOG_ID_RADIO = 1; + static final int LOG_ID_EVENTS = 2; + static final int LOG_ID_SYSTEM = 3; + + static native int println_native(int bufID, int priority, String tag, String msg); } diff --git a/core/java/android/util/Slog.java b/core/java/android/util/Slog.java new file mode 100644 index 000000000000..ecf5ea153c2e --- /dev/null +++ b/core/java/android/util/Slog.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +import com.android.internal.os.RuntimeInit; + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * @hide + */ +public final class Slog { + + private Slog() { + } + + public static int v(String tag, String msg) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.VERBOSE, tag, msg); + } + + public static int v(String tag, String msg, Throwable tr) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.VERBOSE, tag, + msg + '\n' + Log.getStackTraceString(tr)); + } + + public static int d(String tag, String msg) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.DEBUG, tag, msg); + } + + public static int d(String tag, String msg, Throwable tr) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.DEBUG, tag, + msg + '\n' + Log.getStackTraceString(tr)); + } + + public static int i(String tag, String msg) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.INFO, tag, msg); + } + + public static int i(String tag, String msg, Throwable tr) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.INFO, tag, + msg + '\n' + Log.getStackTraceString(tr)); + } + + public static int w(String tag, String msg) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, msg); + } + + public static int w(String tag, String msg, Throwable tr) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, + msg + '\n' + Log.getStackTraceString(tr)); + } + + public static int w(String tag, Throwable tr) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, Log.getStackTraceString(tr)); + } + + public static int e(String tag, String msg) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.ERROR, tag, msg); + } + + public static int e(String tag, String msg, Throwable tr) { + return Log.println_native(Log.LOG_ID_SYSTEM, Log.ERROR, tag, + msg + '\n' + Log.getStackTraceString(tr)); + } + + public static int println(int priority, String tag, String msg) { + return Log.println_native(Log.LOG_ID_SYSTEM, priority, tag, msg); + } +} + |
