Ned Burns | 56a0ea1 | 2019-12-10 17:59:01 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 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 com.android.systemui.log |
| 18 | |
| 19 | /** |
| 20 | * Generic data class for storing messages logged to a [LogBuffer] |
| 21 | * |
| 22 | * Each LogMessage has a few standard fields ([level], [tag], and [timestamp]). The rest are generic |
| 23 | * data slots that may or may not be used, depending on the nature of the specific message being |
| 24 | * logged. |
| 25 | * |
| 26 | * When a message is logged, the code doing the logging stores data in one or more of the generic |
| 27 | * fields ([str1], [int1], etc). When it comes time to dump the message to logcat/bugreport/etc, the |
| 28 | * [printer] function reads the data stored in the generic fields and converts that to a human- |
| 29 | * readable string. Thus, for every log type there must be a specialized initializer function that |
| 30 | * stores data specific to that log type and a specialized printer function that prints that data. |
| 31 | * |
| 32 | * See [LogBuffer.log] for more information. |
| 33 | */ |
| 34 | interface LogMessage { |
| 35 | val level: LogLevel |
| 36 | val tag: String |
| 37 | val timestamp: Long |
| 38 | val printer: LogMessage.() -> String |
| 39 | |
| 40 | var str1: String? |
| 41 | var str2: String? |
| 42 | var str3: String? |
| 43 | var int1: Int |
| 44 | var int2: Int |
| 45 | var long1: Long |
| 46 | var double1: Double |
| 47 | } |