• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.server.art;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Build;
22 import android.util.Log;
23 import android.util.Slog;
24 
25 import androidx.annotation.RequiresApi;
26 
27 /**
28  * A log wrapper that logs messages with the appropriate tag.
29  *
30  * @hide
31  */
32 @RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
33 public class AsLog {
34     private static final String TAG = "ArtService";
35     private static final String PRE_REBOOT_TAG = "ArtServicePreReboot";
36 
37     @NonNull
getTag()38     public static String getTag() {
39         return GlobalInjector.getInstance().isPreReboot() ? PRE_REBOOT_TAG : TAG;
40     }
41 
v(@onNull String msg)42     public static void v(@NonNull String msg) {
43         Log.v(getTag(), msg);
44     }
45 
v(@onNull String msg, @Nullable Throwable tr)46     public static void v(@NonNull String msg, @Nullable Throwable tr) {
47         Log.v(getTag(), msg, tr);
48     }
49 
d(@onNull String msg)50     public static void d(@NonNull String msg) {
51         Log.d(getTag(), msg);
52     }
53 
d(@onNull String msg, @Nullable Throwable tr)54     public static void d(@NonNull String msg, @Nullable Throwable tr) {
55         Log.d(getTag(), msg, tr);
56     }
57 
i(@onNull String msg)58     public static void i(@NonNull String msg) {
59         Log.i(getTag(), msg);
60     }
61 
i(@onNull String msg, @Nullable Throwable tr)62     public static void i(@NonNull String msg, @Nullable Throwable tr) {
63         Log.i(getTag(), msg, tr);
64     }
65 
w(@onNull String msg)66     public static void w(@NonNull String msg) {
67         Log.w(getTag(), msg);
68     }
69 
w(@onNull String msg, @Nullable Throwable tr)70     public static void w(@NonNull String msg, @Nullable Throwable tr) {
71         Log.w(getTag(), msg, tr);
72     }
73 
e(@onNull String msg)74     public static void e(@NonNull String msg) {
75         Log.e(getTag(), msg);
76     }
77 
e(@onNull String msg, @Nullable Throwable tr)78     public static void e(@NonNull String msg, @Nullable Throwable tr) {
79         Log.e(getTag(), msg, tr);
80     }
81 
wtf(@onNull String msg)82     public static void wtf(@NonNull String msg) {
83         Slog.wtf(getTag(), msg);
84     }
85 
wtf(@onNull String msg, @Nullable Throwable tr)86     public static void wtf(@NonNull String msg, @Nullable Throwable tr) {
87         Slog.wtf(getTag(), msg, tr);
88     }
89 }
90