Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 android.util; |
| 18 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 19 | import android.annotation.UnsupportedAppUsage; |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 20 | import android.os.Build; |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 21 | |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 22 | /** |
| 23 | * @hide |
| 24 | */ |
| 25 | public final class Slog { |
| 26 | |
| 27 | private Slog() { |
| 28 | } |
| 29 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 30 | @UnsupportedAppUsage |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 31 | public static int v(String tag, String msg) { |
| 32 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.VERBOSE, tag, msg); |
| 33 | } |
| 34 | |
| 35 | public static int v(String tag, String msg, Throwable tr) { |
| 36 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.VERBOSE, tag, |
| 37 | msg + '\n' + Log.getStackTraceString(tr)); |
| 38 | } |
| 39 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 40 | @UnsupportedAppUsage |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 41 | public static int d(String tag, String msg) { |
| 42 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.DEBUG, tag, msg); |
| 43 | } |
| 44 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 45 | @UnsupportedAppUsage |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 46 | public static int d(String tag, String msg, Throwable tr) { |
| 47 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.DEBUG, tag, |
| 48 | msg + '\n' + Log.getStackTraceString(tr)); |
| 49 | } |
| 50 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 51 | @UnsupportedAppUsage |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 52 | public static int i(String tag, String msg) { |
| 53 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.INFO, tag, msg); |
| 54 | } |
| 55 | |
| 56 | public static int i(String tag, String msg, Throwable tr) { |
| 57 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.INFO, tag, |
| 58 | msg + '\n' + Log.getStackTraceString(tr)); |
| 59 | } |
| 60 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 61 | @UnsupportedAppUsage |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 62 | public static int w(String tag, String msg) { |
| 63 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, msg); |
| 64 | } |
| 65 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 66 | @UnsupportedAppUsage |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 67 | public static int w(String tag, String msg, Throwable tr) { |
| 68 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, |
| 69 | msg + '\n' + Log.getStackTraceString(tr)); |
| 70 | } |
| 71 | |
| 72 | public static int w(String tag, Throwable tr) { |
| 73 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.WARN, tag, Log.getStackTraceString(tr)); |
| 74 | } |
| 75 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 76 | @UnsupportedAppUsage |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 77 | public static int e(String tag, String msg) { |
| 78 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.ERROR, tag, msg); |
| 79 | } |
| 80 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 81 | @UnsupportedAppUsage |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 82 | public static int e(String tag, String msg, Throwable tr) { |
| 83 | return Log.println_native(Log.LOG_ID_SYSTEM, Log.ERROR, tag, |
| 84 | msg + '\n' + Log.getStackTraceString(tr)); |
| 85 | } |
| 86 | |
Dianne Hackborn | 8d05172 | 2014-10-01 14:59:58 -0700 | [diff] [blame] | 87 | /** |
| 88 | * Like {@link Log#wtf(String, String)}, but will never cause the caller to crash, and |
| 89 | * will always be handled asynchronously. Primarily for use by coding running within |
| 90 | * the system process. |
| 91 | */ |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 92 | @UnsupportedAppUsage |
Dianne Hackborn | 164371f | 2013-10-01 19:10:13 -0700 | [diff] [blame] | 93 | public static int wtf(String tag, String msg) { |
Dianne Hackborn | 5232271 | 2014-08-26 22:47:26 -0700 | [diff] [blame] | 94 | return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false, true); |
Dianne Hackborn | 164371f | 2013-10-01 19:10:13 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Dianne Hackborn | 8d05172 | 2014-10-01 14:59:58 -0700 | [diff] [blame] | 97 | /** |
Dianne Hackborn | 1e01d16 | 2014-12-04 17:46:42 -0800 | [diff] [blame] | 98 | * Like {@link #wtf(String, String)}, but does not output anything to the log. |
| 99 | */ |
| 100 | public static void wtfQuiet(String tag, String msg) { |
| 101 | Log.wtfQuiet(Log.LOG_ID_SYSTEM, tag, msg, true); |
| 102 | } |
| 103 | |
| 104 | /** |
Dianne Hackborn | 8d05172 | 2014-10-01 14:59:58 -0700 | [diff] [blame] | 105 | * Like {@link Log#wtfStack(String, String)}, but will never cause the caller to crash, and |
| 106 | * will always be handled asynchronously. Primarily for use by coding running within |
| 107 | * the system process. |
| 108 | */ |
Mathew Inwood | 31755f9 | 2018-12-20 13:53:36 +0000 | [diff] [blame] | 109 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Dianne Hackborn | 164371f | 2013-10-01 19:10:13 -0700 | [diff] [blame] | 110 | public static int wtfStack(String tag, String msg) { |
Dianne Hackborn | 5232271 | 2014-08-26 22:47:26 -0700 | [diff] [blame] | 111 | return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, true, true); |
Dianne Hackborn | 164371f | 2013-10-01 19:10:13 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Dianne Hackborn | 8d05172 | 2014-10-01 14:59:58 -0700 | [diff] [blame] | 114 | /** |
| 115 | * Like {@link Log#wtf(String, Throwable)}, but will never cause the caller to crash, |
| 116 | * and will always be handled asynchronously. Primarily for use by coding running within |
| 117 | * the system process. |
| 118 | */ |
Dianne Hackborn | 164371f | 2013-10-01 19:10:13 -0700 | [diff] [blame] | 119 | public static int wtf(String tag, Throwable tr) { |
Dianne Hackborn | 5232271 | 2014-08-26 22:47:26 -0700 | [diff] [blame] | 120 | return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr, false, true); |
Dianne Hackborn | 164371f | 2013-10-01 19:10:13 -0700 | [diff] [blame] | 121 | } |
| 122 | |
Dianne Hackborn | 8d05172 | 2014-10-01 14:59:58 -0700 | [diff] [blame] | 123 | /** |
| 124 | * Like {@link Log#wtf(String, String, Throwable)}, but will never cause the caller to crash, |
| 125 | * and will always be handled asynchronously. Primarily for use by coding running within |
| 126 | * the system process. |
| 127 | */ |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 128 | @UnsupportedAppUsage |
Dianne Hackborn | 164371f | 2013-10-01 19:10:13 -0700 | [diff] [blame] | 129 | public static int wtf(String tag, String msg, Throwable tr) { |
Dianne Hackborn | 5232271 | 2014-08-26 22:47:26 -0700 | [diff] [blame] | 130 | return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr, false, true); |
Dianne Hackborn | 164371f | 2013-10-01 19:10:13 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Mathew Inwood | 4eb56ab | 2018-08-14 17:24:32 +0100 | [diff] [blame] | 133 | @UnsupportedAppUsage |
Joe Onorato | 00bb938 | 2010-02-26 18:07:01 -0800 | [diff] [blame] | 134 | public static int println(int priority, String tag, String msg) { |
| 135 | return Log.println_native(Log.LOG_ID_SYSTEM, priority, tag, msg); |
| 136 | } |
| 137 | } |
| 138 | |