blob: d33ac4b4a80b3aa220d7e0d9568a730b591b7a95 [file] [log] [blame]
Ned Burns56a0ea12019-12-10 17:59:01 -05001/*
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
17package com.android.systemui.log
18
19/**
20 * Recyclable implementation of [LogMessage].
21 */
22data class LogMessageImpl(
23 override var level: LogLevel,
24 override var tag: String,
25 override var timestamp: Long,
26 override var printer: LogMessage.() -> String,
27 override var str1: String?,
28 override var str2: String?,
29 override var str3: String?,
30 override var int1: Int,
31 override var int2: Int,
32 override var long1: Long,
Ned Burns30d67702020-01-28 12:58:45 -050033 override var long2: Long,
34 override var double1: Double,
35 override var bool1: Boolean,
36 override var bool2: Boolean,
37 override var bool3: Boolean,
38 override var bool4: Boolean
Ned Burns56a0ea12019-12-10 17:59:01 -050039) : LogMessage {
40
41 fun reset(
42 tag: String,
43 level: LogLevel,
44 timestamp: Long,
45 renderer: LogMessage.() -> String
46 ) {
47 this.level = level
48 this.tag = tag
49 this.timestamp = timestamp
50 this.printer = renderer
51 str1 = null
52 str2 = null
53 str3 = null
54 int1 = 0
55 int2 = 0
56 long1 = 0
Ned Burns30d67702020-01-28 12:58:45 -050057 long2 = 0
Ned Burns56a0ea12019-12-10 17:59:01 -050058 double1 = 0.0
Ned Burns30d67702020-01-28 12:58:45 -050059 bool1 = false
60 bool2 = false
61 bool3 = false
62 bool4 = false
Ned Burns56a0ea12019-12-10 17:59:01 -050063 }
64
65 companion object Factory {
66 fun create(): LogMessageImpl {
67 return LogMessageImpl(
68 LogLevel.DEBUG,
69 DEFAULT_TAG,
70 0,
71 DEFAULT_RENDERER,
72 null,
73 null,
74 null,
75 0,
76 0,
77 0,
Ned Burns30d67702020-01-28 12:58:45 -050078 0,
79 0.0,
80 false,
81 false,
82 false,
83 false)
Ned Burns56a0ea12019-12-10 17:59:01 -050084 }
85 }
86}
87
88private const val DEFAULT_TAG = "UnknownTag"
89private val DEFAULT_RENDERER: LogMessage.() -> String = { "Unknown message: $this" }