1 /* 2 * Copyright (C) 2023 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.systemui.log.table 18 19 import android.util.Log 20 import javax.inject.Inject 21 22 /** Dagger-friendly interface so we can inject a fake [android.util.Log] in tests */ 23 interface LogProxy { 24 /** verbose log */ 25 fun v(tag: String, message: String) 26 27 /** debug log */ 28 fun d(tag: String, message: String) 29 30 /** info log */ 31 fun i(tag: String, message: String) 32 33 /** warning log */ 34 fun w(tag: String, message: String) 35 36 /** error log */ 37 fun e(tag: String, message: String) 38 39 /** wtf log */ 40 fun wtf(tag: String, message: String) 41 } 42 43 class LogProxyDefault @Inject constructor() : LogProxy { 44 override fun v(tag: String, message: String) { 45 Log.v(tag, message) 46 } 47 48 override fun d(tag: String, message: String) { 49 Log.d(tag, message) 50 } 51 52 override fun i(tag: String, message: String) { 53 Log.i(tag, message) 54 } 55 56 override fun w(tag: String, message: String) { 57 Log.w(tag, message) 58 } 59 60 override fun e(tag: String, message: String) { 61 Log.e(tag, message) 62 } 63 64 override fun wtf(tag: String, message: String) { 65 Log.wtf(tag, message) 66 } 67 } 68