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