• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.app.sdksandbox;
18 
19 import android.util.Log;
20 
21 /**
22  * Utility class for logging behind {@link Log#isLoggable} check.
23  *
24  * <p>Logging can be enabled by running {@code adb shell setprop persist.log.tag.SDK_SANDBOX DEBUG}
25  * or individual tag used while logging with {@link LogUtil}.
26  *
27  * @hide
28  */
29 public class LogUtil {
30 
31     public static final String GUARD_TAG = "SDK_SANDBOX";
32 
33     /** Log the message as VERBOSE. Return The number of bytes written. */
v(String tag, String msg)34     public static int v(String tag, String msg) {
35         if (Log.isLoggable(GUARD_TAG, Log.VERBOSE) || Log.isLoggable(tag, Log.VERBOSE)) {
36             return Log.v(tag, msg);
37         }
38         return 0;
39     }
40 
41     /** Log the message as DEBUG. Return The number of bytes written. */
d(String tag, String msg)42     public static int d(String tag, String msg) {
43         if (Log.isLoggable(GUARD_TAG, Log.DEBUG) || Log.isLoggable(tag, Log.DEBUG)) {
44             return Log.d(tag, msg);
45         }
46         return 0;
47     }
48 }
49