Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow turning off logging with Level.OFF #313

Merged
merged 2 commits into from
May 31, 2023

Conversation

YarnSphere
Copy link
Contributor

Fixes #310.

I added the minimum amount of code to make this work, together with a test for JS and native.

It might make sense to add an isOff property to KLogger (which could probably even be implemented in common code as !isErrorEnabled), let me know what you think.

@oshai
Copy link
Owner

oshai commented May 18, 2023

the PR lgtm thanks!
Adding a method sounds good. Maybe call is isLoggingOff?

@YarnSphere
Copy link
Contributor Author

Got it, I'll give it a go when I have a few more minutes to spare. Feel free to push to this branch if you manage to get to it before I do.

@YarnSphere YarnSphere force-pushed the logging-level-off branch 2 times, most recently from 9f5b223 to a32434b Compare May 21, 2023 16:24
@oshai
Copy link
Owner

oshai commented May 24, 2023

Thanks!
Why didn't you implement it as !isErrorEnabled in the common interface? Isn't it enough?
Sounds like a good default.

@YarnSphere
Copy link
Contributor Author

My reasoning was that some implementations have their own notion of "off", so I thought it's better to defer to them on what they consider to be "off". Also, for consistency with the rest of the isLevelEnabled implementations.

The Android logging, for example, has the level ASSERT after ERROR, so OFF wouldn't be truly "off" due to assert logs.

JUL allows subclassing and defining custom levels between SEVERE (1000) and OFF (Integer.MAX_VALUE), I'm not sure if this would ever be supported, but in such a case this implementation would hold.

Either way, if you'd prefer it as a common implementation with a simple !isErrorEnabled let me know. Also let me know if the JVM isLoggingOff function receiving a marker makes sense or whether we should remove it.

@oshai
Copy link
Owner

oshai commented May 31, 2023

Thanks! Since I am doing other changes in #320 I am going to merge this one before to avoid conflicts.

Might change some things that were discussed in previous comments later.

@oshai oshai merged commit 2098a6f into oshai:master May 31, 2023
5 checks passed
nikclayton pushed a commit to pachli/pachli-android that referenced this pull request Nov 17, 2023
….0.2 (#106)

[![Mend Renovate logo
banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[io.github.oshai:kotlin-logging-jvm](https://togithub.com/oshai/kotlin-logging)
| `4.0.0-beta-28` -> `4.0.2` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/io.github.oshai:kotlin-logging-jvm/4.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/io.github.oshai:kotlin-logging-jvm/4.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/io.github.oshai:kotlin-logging-jvm/4.0.0-beta-28/4.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/io.github.oshai:kotlin-logging-jvm/4.0.0-beta-28/4.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>oshai/kotlin-logging
(io.github.oshai:kotlin-logging-jvm)</summary>

###
[`v4.0.1`](https://togithub.com/oshai/kotlin-logging/releases/tag/4.0.1)

[Compare
Source](https://togithub.com/oshai/kotlin-logging/compare/4.0.0...4.0.1)

#### What's Changed

- Bump org.jetbrains.dokka from 1.8.10 to 1.8.20 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#324
- Bump multiplatform from 1.8.20 to 1.8.22 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#326
- Bump com.diffplug.spotless from 6.17.0 to 6.19.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#325
- change android to depend on slf4j2 by default by
[@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#328

**Full Changelog**:
oshai/kotlin-logging@4.0.0...4.0.1

###
[`v4.0.0`](https://togithub.com/oshai/kotlin-logging/releases/tag/4.0.0)

[Compare
Source](https://togithub.com/oshai/kotlin-logging/compare/4.0.0-beta-30...4.0.0)

For TL;DR see
https://github.com/oshai/kotlin-logging#version-4x-vs-previous-versions

#### What's Changed

- 4.x changes by [@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#269
- add missing klogger common methods by
[@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#272
- removed some code duplication by
[@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#273
- initial android support by [@&#8203;oshai](https://togithub.com/oshai)
in
[oshai/kotlin-logging#271
- AGP 7.3.1 by [@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#274
- add javaMain module and remove duplication by
[@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#275
- fix log level check for
[#&#8203;276](https://togithub.com/oshai/kotlin-logging/issues/276) by
[@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#277
- fix logger name in messages by
[@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#280
- add withLoggingContextAsync by
[@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#278
- add native simple test by [@&#8203;oshai](https://togithub.com/oshai)
in
[oshai/kotlin-logging#281
- fixed some warnings by [@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#282
- add js delegate by [@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#283
- build(deps): bump log4j2 from 2.19.0 to 2.20.0 by
[@&#8203;yeikel](https://togithub.com/yeikel) in
[oshai/kotlin-logging#284
- ci: add Gradle wrapper validation by
[@&#8203;yeikel](https://togithub.com/yeikel) in
[oshai/kotlin-logging#285
- build(deps-dev): bump Junit from 5.9.1 to 5.9.2 by
[@&#8203;yeikel](https://togithub.com/yeikel) in
[oshai/kotlin-logging#287
- build(deps-dev): bump mockito from 4.8.0 to 4.11.0 by
[@&#8203;yeikel](https://togithub.com/yeikel) in
[oshai/kotlin-logging#286
- build: bump gradle wrapper to 7.6.1 by
[@&#8203;yeikel](https://togithub.com/yeikel) in
[oshai/kotlin-logging#289
- Add dependabot configuration by
[@&#8203;yeikel](https://togithub.com/yeikel) in
[oshai/kotlin-logging#291
- chore(dependabot): fix indentation by
[@&#8203;yeikel](https://togithub.com/yeikel) in
[oshai/kotlin-logging#292
- Bump actions/checkout from 2 to 3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#299
- Bump com.android.library from 7.3.1 to 7.4.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#294
- Bump org.jetbrains.dokka from 1.7.10 to 1.8.10 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#297
- Bump com.diffplug.spotless from 5.12.4 to 6.17.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#300
- Bump io.github.gradle-nexus.publish-plugin from 1.1.0 to 1.3.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#298
- Bump actions/cache from 2.1.7 to 3.3.1 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#296
- Bump actions/setup-java from 1 to 3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#293
- Bump multiplatform from 1.8.10 to 1.8.20 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#302
- ci: use temurin by [@&#8203;yeikel](https://togithub.com/yeikel) in
[oshai/kotlin-logging#301
- Allow turning off logging with `Level.OFF` by
[@&#8203;YarnSphere](https://togithub.com/YarnSphere) in
[oshai/kotlin-logging#313
- change package - add kotlinlogging by
[@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#320
- Bump multiplatform from 1.8.20 to 1.8.22 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#321
- Bump org.jetbrains.dokka from 1.8.10 to 1.8.20 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#322
- Bump com.diffplug.spotless from 6.17.0 to 6.19.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#317

#### New Contributors

- [@&#8203;dependabot](https://togithub.com/dependabot) made their first
contribution in
[oshai/kotlin-logging#299

**Full Changelog**:
oshai/kotlin-logging@3.0.5...4.0.0

###
[`v4.0.0-beta-30`](https://togithub.com/oshai/kotlin-logging/releases/tag/4.0.0-beta-30)

[Compare
Source](https://togithub.com/oshai/kotlin-logging/compare/4.0.0-beta-29...4.0.0-beta-30)

#### What's Changed

- Bump multiplatform from 1.8.20 to 1.8.22 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#321
- Bump org.jetbrains.dokka from 1.8.10 to 1.8.20 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#322
- Bump com.diffplug.spotless from 6.17.0 to 6.19.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[oshai/kotlin-logging#317

**Full Changelog**:
oshai/kotlin-logging@4.0.0-beta-29...4.0.0-beta-30

###
[`v4.0.0-beta-29`](https://togithub.com/oshai/kotlin-logging/releases/tag/4.0.0-beta-29)

#### What's Changed

- Allow turning off logging with `Level.OFF` by
[@&#8203;YarnSphere](https://togithub.com/YarnSphere) in
[oshai/kotlin-logging#313
- change package - add kotlinlogging by
[@&#8203;oshai](https://togithub.com/oshai) in
[oshai/kotlin-logging#320

**Full Changelog**:
oshai/kotlin-logging@4.0.0-beta-27...4.0.0-beta-29

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/pachli/pachli-android).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDcuMiIsInVwZGF0ZWRJblZlciI6IjM3LjQ2LjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support turning off logging in platforms other than the JVM
2 participants