Skip to content

Commit d043bff

Browse files
committed
add back FirebaseDataConnect.logging, but marked as deprecated, so as to NOT be a breaking change
1 parent c857323 commit d043bff

File tree

4 files changed

+76
-4
lines changed

4 files changed

+76
-4
lines changed

firebase-dataconnect/CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Unreleased
2-
* [changed] *Breaking Change* `FirebaseDataConnect.logLevel` changed to
3-
`FirebaseDataConnect.logging` to provide more fine-grained control and access
4-
to the logcat logging facilities, such as a `Flow` to collect the log level
5-
changes and `push()` to easily set and restore the log level.
2+
* [feature] `FirebaseDataConnect.logging` added, to provide more advanced
3+
control and access to the logcat logging facilities, such as a `Flow` to
4+
collect the log level changes and `push()` to easily set and restore the log
5+
level.
66
([#NNNN](https://github.com/firebase/firebase-android-sdk/pull/NNNN))
77

88
# 16.0.0-beta03

firebase-dataconnect/api.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ package com.google.firebase.dataconnect {
130130
public final class FirebaseDataConnectKt {
131131
method @NonNull public static com.google.firebase.dataconnect.FirebaseDataConnect getInstance(@NonNull com.google.firebase.dataconnect.FirebaseDataConnect.Companion, @NonNull com.google.firebase.FirebaseApp app, @NonNull com.google.firebase.dataconnect.ConnectorConfig config, @NonNull com.google.firebase.dataconnect.DataConnectSettings settings = com.google.firebase.dataconnect.DataConnectSettings());
132132
method @NonNull public static com.google.firebase.dataconnect.FirebaseDataConnect getInstance(@NonNull com.google.firebase.dataconnect.FirebaseDataConnect.Companion, @NonNull com.google.firebase.dataconnect.ConnectorConfig config, @NonNull com.google.firebase.dataconnect.DataConnectSettings settings = com.google.firebase.dataconnect.DataConnectSettings());
133+
method @Deprecated @NonNull public static com.google.firebase.dataconnect.LogLevel getLogLevel(@NonNull com.google.firebase.dataconnect.FirebaseDataConnect.Companion);
133134
method @NonNull public static com.google.firebase.dataconnect.DataConnectLogging getLogging(@NonNull com.google.firebase.dataconnect.FirebaseDataConnect.Companion);
135+
method @Deprecated public static void setLogLevel(@NonNull com.google.firebase.dataconnect.FirebaseDataConnect.Companion, @NonNull com.google.firebase.dataconnect.LogLevel);
134136
}
135137

136138
@kotlinx.serialization.Serializable(with=LocalDateSerializer::class) public final class LocalDate {

firebase-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/FirebaseDataConnect.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,23 @@ public fun FirebaseDataConnect.Companion.getInstance(
378378
settings: DataConnectSettings = DataConnectSettings()
379379
): FirebaseDataConnect = getInstance(app = Firebase.app, config = config, settings = settings)
380380

381+
/**
382+
* The log level used by all [FirebaseDataConnect] instances.
383+
*
384+
* The default log level is [LogLevel.WARN]. Setting this to [LogLevel.DEBUG] will enable debug
385+
* logging, which is especially useful when reporting issues to Google or investigating problems
386+
* yourself. Setting it to [LogLevel.NONE] will disable all logging.
387+
*/
388+
@Deprecated(
389+
message = "Will be removed when Data Connect graduates from beta",
390+
replaceWith = ReplaceWith("logging.level", "com.google.firebase.dataconnect.logging")
391+
)
392+
public var FirebaseDataConnect.Companion.logLevel: LogLevel
393+
get() = logging.level
394+
set(level) {
395+
logging.level = level
396+
}
397+
381398
/** The logcat logging facilities used by all [FirebaseDataConnect] instances. */
382399
public val FirebaseDataConnect.Companion.logging: DataConnectLogging
383400
get() = DataConnectLoggingImpl
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2024 Google LLC
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+
package com.google.firebase.dataconnect
17+
18+
import io.kotest.matchers.shouldBe
19+
import io.kotest.property.Arb
20+
import io.kotest.property.arbitrary.enum
21+
import io.kotest.property.checkAll
22+
import kotlinx.coroutines.test.runTest
23+
import org.junit.Test
24+
25+
class FirebaseDataConnectUnitTest {
26+
27+
@Test
28+
@Suppress("DEPRECATION")
29+
fun `logLevel set and get`() = runTest {
30+
checkAll(Arb.enum<LogLevel>()) { newLevel ->
31+
FirebaseDataConnect.logLevel = newLevel
32+
FirebaseDataConnect.logLevel shouldBe newLevel
33+
}
34+
}
35+
36+
@Test
37+
@Suppress("DEPRECATION")
38+
fun `logLevel set should forward to logging dot level`() = runTest {
39+
checkAll(Arb.enum<LogLevel>()) { newLevel ->
40+
FirebaseDataConnect.logLevel = newLevel
41+
FirebaseDataConnect.logging.level shouldBe newLevel
42+
}
43+
}
44+
45+
@Test
46+
@Suppress("DEPRECATION")
47+
fun `logLevel get should retrieve from logging dot level`() = runTest {
48+
checkAll(Arb.enum<LogLevel>()) { newLevel ->
49+
FirebaseDataConnect.logging.level = newLevel
50+
FirebaseDataConnect.logLevel shouldBe newLevel
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)