Skip to content

Commit 42b18d0

Browse files
committed
feat: misleading method name
1 parent 6a7bf3b commit 42b18d0

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

src/main/java/io/github/numichi/reactive/logger/coroutine/ACoroutine.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,18 @@ abstract class ACoroutine<T : IReactorLogger>(
4040
return this
4141
}
4242

43-
fun withEnableError(enableError: Boolean): Builder<E, L, R> {
44-
this.enableError = enableError
43+
@Deprecated(
44+
message = "It can be misleading due to enabling word in method name and boolean parameter. Use: withError(boolean); False by default",
45+
replaceWith = ReplaceWith("withError(enable)"),
46+
level = DeprecationLevel.WARNING
47+
)
48+
fun withEnableError(enable: Boolean): Builder<E, L, R> {
49+
this.enableError = enable
50+
return this
51+
}
52+
53+
fun withError(enable: Boolean = true): Builder<E, L, R> {
54+
this.enableError = enable
4555
return this
4656
}
4757

src/main/java/io/github/numichi/reactive/logger/reactor/AReactive.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,19 @@ abstract class AReactive(
2828
return this;
2929
}
3030

31-
fun withEnableError(enableError: Boolean): Builder<L, R> {
32-
this.enableError = enableError
33-
return this;
31+
@Deprecated(
32+
message = "It can be misleading due to enabling word in method name and boolean parameter. Use: withError(boolean); False by default",
33+
replaceWith = ReplaceWith("withError(enableError)"),
34+
level = DeprecationLevel.WARNING
35+
)
36+
fun withEnableError(enable: Boolean): Builder<L, R> {
37+
this.enableError = enable
38+
return this
39+
}
40+
41+
fun withError(enable: Boolean = true): Builder<L, R> {
42+
this.enableError = enable
43+
return this
3444
}
3545

3646
fun withLogger(logger: L): Builder<L, R> {

src/test/java/io/github/numichi/reactive/logger/coroutine/CoroutineKLoggerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal class CoroutineKLoggerTest {
3333
private val imperativeLogger: KLogger = mockk(relaxed = true)
3434
private val logger: ICoroutineKLogger = CoroutineKLogger.reactorBuilder().withLogger(imperativeLogger).build()
3535
private val loggerScheduled: ICoroutineKLogger = CoroutineKLogger.reactorBuilder().withLogger(imperativeLogger).withScheduler(Schedulers.parallel()).build()
36-
private val loggerWithError: ICoroutineKLogger = CoroutineKLogger.reactorBuilder().withLogger(imperativeLogger).withEnableError(true).build()
36+
private val loggerWithError: ICoroutineKLogger = CoroutineKLogger.reactorBuilder().withLogger(imperativeLogger).withError().build()
3737

3838
companion object {
3939
@JvmStatic

src/test/java/io/github/numichi/reactive/logger/coroutine/CoroutineLoggerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal class CoroutineLoggerTest {
3232
private val imperativeLogger: Logger = mockk(relaxed = true)
3333
private val logger = CoroutineLogger.reactorBuilder().withLogger(imperativeLogger).build()
3434
private val loggerScheduled = CoroutineLogger.reactorBuilder().withLogger(imperativeLogger).withScheduler(Schedulers.parallel()).build()
35-
private val loggerWithError = CoroutineLogger.reactorBuilder().withLogger(imperativeLogger).withEnableError(true).build()
35+
private val loggerWithError = CoroutineLogger.reactorBuilder().withLogger(imperativeLogger).withError(true).build()
3636

3737
companion object {
3838
@JvmStatic

src/test/java/io/github/numichi/reactive/logger/coroutine/CoroutineOtherTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ internal class CoroutineOtherTest {
3030
.withContextKey(ReactorContext)
3131
.withContextExtractive { coroutineContext[it]?.context }
3232
.withScheduler(Schedulers.boundedElastic())
33-
.withEnableError(false)
3433
.withMDCContextKey("other-key")
3534
.withLogger(mockKLogger)
3635
.build()
@@ -45,7 +44,6 @@ internal class CoroutineOtherTest {
4544
.withContextKey(ReactorContext)
4645
.withContextExtractive { coroutineContext[it]?.context }
4746
.withScheduler(Schedulers.boundedElastic())
48-
.withEnableError(false)
4947
.withMDCContextKey("other-key")
5048
.withLogger(mockLogger)
5149
.build()
@@ -181,7 +179,7 @@ internal class CoroutineOtherTest {
181179
@Test
182180
fun `should throw exception from snapshot`() {
183181
val logger = CoroutineLogger.reactorBuilder()
184-
.withEnableError(true)
182+
.withError(true)
185183
.withLogger(mockk(relaxed = true))
186184
.build()
187185

src/test/java/io/github/numichi/reactive/logger/reactor/ReactiveKLoggerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import java.util.*
3737
internal class ReactiveKLoggerTest {
3838
private val imperativeLogger: KLogger = mockk(relaxed = true)
3939
private val logger = builder().withLogger(imperativeLogger).build()
40-
private val loggerWithError = builder().withLogger(imperativeLogger).withEnableError(true).build()
40+
private val loggerWithError = builder().withLogger(imperativeLogger).withError().build()
4141

4242
companion object {
4343
fun randomText(): String {

src/test/java/io/github/numichi/reactive/logger/reactor/ReactiveLoggerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import java.util.*
3636
internal class ReactiveLoggerTest {
3737
private val imperativeLogger: Logger = mockk(relaxed = true)
3838
private val logger = builder().withLogger(imperativeLogger).build()
39-
private val loggerWithError = builder().withLogger(imperativeLogger).withEnableError(true).build()
39+
private val loggerWithError = builder().withLogger(imperativeLogger).withError().build()
4040

4141
companion object {
4242
fun randomText(): String {

0 commit comments

Comments
 (0)