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 com.android.settingslib.spa.framework.common 18 19 import android.os.Bundle 20 21 // Defines the category of the log, for quick filter 22 enum class LogCategory { 23 // The default category, for logs from Pages & their Models. 24 DEFAULT, 25 26 // For logs from Spa Framework, such as BrowseActivity, EntryProvider 27 FRAMEWORK, 28 29 // For logs from Spa UI components, such as Widgets, Scaffold 30 VIEW, 31 } 32 33 // Defines the log events in Spa. 34 enum class LogEvent { 35 // Page related events. 36 PAGE_ENTER, 37 PAGE_LEAVE, 38 39 // Entry related events. 40 ENTRY_CLICK, 41 ENTRY_SWITCH, 42 } 43 44 internal const val LOG_DATA_DISPLAY_NAME = "name" 45 internal const val LOG_DATA_SWITCH_STATUS = "switch" 46 47 const val LOG_DATA_SESSION_NAME = "session" 48 const val LOG_DATA_METRICS_CATEGORY = "metricsCategory" 49 50 /** 51 * The interface of logger in Spa 52 */ 53 interface SpaLogger { 54 // log a message, usually for debug purpose. messagenull55 fun message(tag: String, msg: String, category: LogCategory = LogCategory.DEFAULT) {} 56 57 // log a user event. eventnull58 fun event( 59 id: String, 60 event: LogEvent, 61 category: LogCategory = LogCategory.DEFAULT, 62 extraData: Bundle = Bundle.EMPTY 63 ) { 64 } 65 } 66