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 import com.android.systemui.log.core.LogLevel 20 import com.android.systemui.log.core.LogMessage 21 import com.android.systemui.log.core.MessagePrinter 22 23 /** Recyclable implementation of [LogMessage]. */ 24 data class LogMessageImpl( 25 override var level: LogLevel, 26 override var tag: String, 27 override var timestamp: Long, 28 override var messagePrinter: MessagePrinter, 29 override var exception: Throwable?, 30 override var str1: String?, 31 override var str2: String?, 32 override var str3: String?, 33 override var int1: Int, 34 override var int2: Int, 35 override var long1: Long, 36 override var long2: Long, 37 override var double1: Double, 38 override var bool1: Boolean, 39 override var bool2: Boolean, 40 override var bool3: Boolean, 41 override var bool4: Boolean, 42 ) : LogMessage { 43 44 fun reset( 45 tag: String, 46 level: LogLevel, 47 timestamp: Long, 48 renderer: MessagePrinter, 49 exception: Throwable? = null, 50 ) { 51 this.level = level 52 this.tag = tag 53 this.timestamp = timestamp 54 this.messagePrinter = renderer 55 this.exception = exception 56 str1 = null 57 str2 = null 58 str3 = null 59 int1 = 0 60 int2 = 0 61 long1 = 0 62 long2 = 0 63 double1 = 0.0 64 bool1 = false 65 bool2 = false 66 bool3 = false 67 bool4 = false 68 } 69 70 companion object Factory { 71 fun create(): LogMessageImpl { 72 return LogMessageImpl( 73 LogLevel.DEBUG, 74 DEFAULT_TAG, 75 0, 76 DEFAULT_PRINTER, 77 null, 78 null, 79 null, 80 null, 81 0, 82 0, 83 0, 84 0, 85 0.0, 86 false, 87 false, 88 false, 89 false 90 ) 91 } 92 } 93 } 94 95 private const val DEFAULT_TAG = "UnknownTag" 96 private val DEFAULT_PRINTER: MessagePrinter = { "Unknown message: $this" } 97