1 /* 2 * Copyright 2020 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 androidx.startup; 18 19 import android.util.Log; 20 21 import androidx.annotation.RestrictTo; 22 23 import org.jspecify.annotations.NonNull; 24 import org.jspecify.annotations.Nullable; 25 26 /** 27 */ 28 @RestrictTo(RestrictTo.Scope.LIBRARY) 29 @SuppressWarnings("WeakerAccess") 30 public final class StartupLogger { 31 StartupLogger()32 private StartupLogger() { 33 // Does nothing. 34 } 35 36 /** 37 * The log tag. 38 */ 39 private static final String TAG = "StartupLogger"; 40 41 /** 42 * To enable logging set this to true. 43 */ 44 static final boolean DEBUG = false; 45 46 /** 47 * Info level logging. 48 * 49 * @param message The message being logged 50 */ i(@onNull String message)51 public static void i(@NonNull String message) { 52 Log.i(TAG, message); 53 } 54 55 /** 56 * Warning level logging. 57 * 58 * @param message The message being logged 59 */ w(@onNull String message)60 public static void w(@NonNull String message) { 61 Log.w(TAG, message); 62 } 63 64 /** 65 * Error level logging 66 * 67 * @param message The message being logged 68 * @param throwable The optional {@link Throwable} exception 69 */ e(@onNull String message, @Nullable Throwable throwable)70 public static void e(@NonNull String message, @Nullable Throwable throwable) { 71 Log.e(TAG, message, throwable); 72 } 73 } 74