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 package com.android.server.bluetooth 17 18 import android.util.Log 19 20 private const val SYSTEM_SERVER_TAG = "BluetoothSystemServer" 21 22 public class Log private constructor() { 23 companion object { 24 25 // Kotlin could shorten below method by having a Throwable? that is default to null but the 26 // current implementation of util.Log is behaving differently depending if it is called with 27 // 2 or 3 parameters. We do not want to change the behavior in this class, just add a common 28 // TAG to all the Bluetooth System Server logs. 29 30 @JvmStatic vnull31 fun v(subtag: String, msg: String) = Log.v(SYSTEM_SERVER_TAG, "${subtag}: ${msg}") 32 33 @JvmStatic 34 fun d(subtag: String, msg: String) = Log.d(SYSTEM_SERVER_TAG, "${subtag}: ${msg}") 35 36 @JvmStatic 37 fun i(subtag: String, msg: String) = Log.i(SYSTEM_SERVER_TAG, "${subtag}: ${msg}") 38 39 @JvmStatic 40 fun w(subtag: String, msg: String) = Log.w(SYSTEM_SERVER_TAG, "${subtag}: ${msg}") 41 42 @JvmStatic 43 fun w(subtag: String, msg: String, tr: Throwable) = 44 Log.w(SYSTEM_SERVER_TAG, "${subtag}: ${msg}", tr) 45 46 @JvmStatic 47 fun e(subtag: String, msg: String) = Log.e(SYSTEM_SERVER_TAG, "${subtag}: ${msg}") 48 49 @JvmStatic 50 fun e(subtag: String, msg: String, tr: Throwable) = 51 Log.e(SYSTEM_SERVER_TAG, "${subtag}: ${msg}", tr) 52 } 53 } 54