Skip to content

Replace org.slf4j.event.Level with an OSHI-owned LogLevel enum - #3525

Merged
dbwiddis merged 6 commits into
oshi:masterfrom
wolfs:oshi-3524-slf4j-event-level
Jul 23, 2026
Merged

dbwiddis merged 6 commits into
oshi:masterfrom
wolfs:oshi-3524-slf4j-event-level

Conversation

@wolfs

@wolfs wolfs commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

ExceptionUtil and its callers across oshi-common, oshi-core, and oshi-core-ffm carried the log level as org.slf4j.event.Level, a type that only exists from slf4j-api 1.7.15 and was referenced on non-exceptional code paths (e.g. the getOrDefault convenience overloads delegate with an explicit Level.DEBUG, and call sites pass Level.WARN as a plain argument). Embedders relying on a host-provided slf4j older than 1.7.15 -- such as a Java agent loaded as an Apache Maven 3.3.x core extension, which resolves slf4j from Maven's bundled 1.7.5 -- therefore hit NoClassDefFoundError: org/slf4j/event/Level on ordinary calls, not just when an exception was actually logged (#3524).

logAtLevel dispatches only to the classic Logger#debug/info/warn/error/trace methods (present since slf4j 1.0), so carrying the level with an OSHI enum removes the 1.7.15 floor without changing any logging behavior. The now-unused org.slf4j.event OSGi import is dropped as well.

Split the SLF4J 1.7 compatibility check into two profiles, since no single 1.7.x version exercises both constraints: verify-slf4j-17 pins 1.7.5 (the API floor) and skips module-info, because Automatic-Module-Name: org.slf4j only arrived in 1.7.27; verify-slf4j-17-jpms pins 1.7.27 and compiles module-info to keep verifying that requires org.slf4j resolves on the module path. Both run in CI.

Summary by CodeRabbit

  • New Features

    • Added OSHI-native logging levels for consistent exception and diagnostic handling.
  • Bug Fixes

    • Improved compatibility with environments providing older SLF4J versions.
    • Prevented unnecessary loading of newer SLF4J logging classes during normal operation.
    • Updated platform-specific diagnostics to preserve existing warning, error, debug, and trace behavior.

ExceptionUtil and its callers across oshi-common, oshi-core, and oshi-core-ffm
carried the log level as org.slf4j.event.Level, a type that only exists from
slf4j-api 1.7.15 and was referenced on non-exceptional code paths (e.g. the
getOrDefault convenience overloads delegate with an explicit Level.DEBUG, and
call sites pass Level.WARN as a plain argument). Embedders relying on a
host-provided slf4j older than 1.7.15 -- such as a Java agent loaded as an
Apache Maven 3.3.x core extension, which resolves slf4j from Maven's bundled
1.7.5 -- therefore hit NoClassDefFoundError: org/slf4j/event/Level on ordinary
calls, not just when an exception was actually logged (oshi#3524).

logAtLevel dispatches only to the classic Logger#debug/info/warn/error/trace
methods (present since slf4j 1.0), so carrying the level with an OSHI enum
removes the 1.7.15 floor without changing any logging behavior. The now-unused
org.slf4j.event OSGi import is dropped as well.

Split the SLF4J 1.7 compatibility check into two profiles, since no single
1.7.x version exercises both constraints: verify-slf4j-17 pins 1.7.5 (the API
floor) and skips module-info, because Automatic-Module-Name: org.slf4j only
arrived in 1.7.27; verify-slf4j-17-jpms pins 1.7.27 and compiles module-info to
keep verifying that `requires org.slf4j` resolves on the module path. Both run
in CI.
Copilot AI review requested due to automatic review settings July 23, 2026 10:05
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 42a1895a-b938-414d-b224-cedbc4588419

📥 Commits

Reviewing files that changed from the base of the PR and between 6364b81 and 0742db9.

📒 Files selected for processing (2)
  • oshi-common/src/main/java/oshi/util/LogLevel.java
  • pom.xml
💤 Files with no reviewable changes (1)
  • oshi-common/src/main/java/oshi/util/LogLevel.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (11)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, ubuntu-latest
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🔇 Additional comments (1)
pom.xml (1)

94-94: LGTM!

Also applies to: 1143-1150


📝 Walkthrough

Walkthrough

OSHI introduces oshi.util.LogLevel and replaces org.slf4j.event.Level across exception helpers, FFM and JNA utilities, platform callers, tests, and compatibility configuration.

Changes

LogLevel migration

Layer / File(s) Summary
Common logging contract and exception helpers
oshi-common/src/main/java/oshi/util/LogLevel.java, oshi-common/src/main/java/oshi/util/ExceptionUtil.java, oshi-common/src/test/java/oshi/util/ExceptionUtilTest.java
Adds five OSHI log levels and updates exception-logging overloads and tests to use them.
FFM helper APIs and callers
oshi-core-ffm/src/main/java/oshi/ffm/**, oshi-core-ffm/src/main/java/oshi/driver/**, oshi-core-ffm/src/main/java/oshi/hardware/**, oshi-core-ffm/src/main/java/oshi/software/**
Changes FFM helper parameters and platform logging constants from SLF4J Level to LogLevel without changing query fallbacks or data handling.
JNA sysctl and performance helpers
oshi-core/src/main/java/oshi/jna/**, oshi-core/src/main/java/oshi/util/platform/**, oshi-core/src/test/java/oshi/util/platform/**
Updates sysctl and performance helper level types, callers, and level-coverage tests.
SLF4J compatibility validation
config/forbidden-apis.txt, pom.xml, CHANGELOG.md
Forbids org.slf4j.event.Level, removes its explicit OSGi import, and documents the migration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: copilot, dbwiddis

Poem

A rabbit swapped the levels bright,
From SLF4J’s old moonlight.
TRACE and WARN now hop in line,
With ERROR, DEBUG, INFO fine.
Old hosts breathe, no classes fall—
LogLevel leads them all!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing SLF4J Level with OSHI's LogLevel enum.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes OSHI’s runtime dependency on org.slf4j.event.Level by introducing an OSHI-owned oshi.util.LogLevel enum and updating ExceptionUtil (and related helpers/callers across oshi-common, oshi-core, and oshi-core-ffm) to carry logging levels without class-loading SLF4J types that are absent in older 1.7.x releases (fixing #3524).

Changes:

  • Add oshi.util.LogLevel and replace org.slf4j.event.Level usages across the codebase.
  • Update ExceptionUtil/FFM/JNA sysctl helpers and platform utilities to accept LogLevel.
  • Adjust Maven/CI verification to test both the SLF4J 1.7.5 API floor and JPMS resolution against SLF4J 1.7.27, and drop the now-unused OSGi import for org.slf4j.event.

Reviewed changes

Copilot reviewed 62 out of 62 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pom.xml Drops OSGi import of org.slf4j.event and splits SLF4J 1.7 compatibility checks into API-floor vs JPMS profiles.
.github/workflows/pr.yaml Runs the new SLF4J 1.7 JPMS compatibility build in CI.
CHANGELOG.md Documents the behavioral/compatibility fix for #3524.
oshi-common/src/main/java/oshi/util/LogLevel.java Introduces an OSHI-owned log level enum to avoid SLF4J event.Level linkage.
oshi-common/src/main/java/oshi/util/ExceptionUtil.java Switches exception-level dispatch from SLF4J Level to OSHI LogLevel.
oshi-common/src/test/java/oshi/util/ExceptionUtilTest.java Updates tests to use LogLevel and validates behavior across all levels.
oshi-core/src/main/java/oshi/util/platform/windows/PerfDataUtil.java Replaces SLF4J Level with LogLevel for Windows PDH error logging decisions.
oshi-core/src/test/java/oshi/util/platform/windows/PerfDataUtilTest.java Updates tests to iterate over LogLevel values.
oshi-core/src/main/java/oshi/util/platform/unix/openbsd/OpenBsdSysctlUtil.java Passes OSHI LogLevel into shared sysctl helper calls.
oshi-core/src/main/java/oshi/util/platform/unix/netbsd/NetBsdSysctlUtil.java Passes OSHI LogLevel into shared sysctl helper calls.
oshi-core/src/main/java/oshi/util/platform/unix/freebsd/BsdSysctlUtil.java Passes OSHI LogLevel into shared sysctl helper calls.
oshi-core/src/main/java/oshi/util/platform/mac/SysctlUtil.java Passes OSHI LogLevel into shared sysctl helper calls.
oshi-core/src/main/java/oshi/jna/util/SysctlUtilJNA.java Changes sysctl helper signatures from SLF4J Level to OSHI LogLevel.
oshi-core-ffm/src/main/java/oshi/ffm/ForeignFunctions.java Switches arena-call helpers to carry LogLevel and reuse ExceptionUtil.logAtLevel.
oshi-core-ffm/src/test/java/oshi/ffm/ForeignFunctionsTest.java Updates tests to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/windows/WindowsOperatingSystemFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/unix/solaris/SolarisOperatingSystemFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/unix/openbsd/OpenBsdOSProcessFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/unix/openbsd/OpenBsdOperatingSystemFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcessFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystemFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParamsFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcessFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystemFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/mac/MacOSProcessFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/mac/MacOSFileStoreFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/mac/MacOperatingSystemFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/mac/MacNetworkParamsFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/mac/MacInternetProtocolStatsFFM.java Updates static imports and ExceptionUtil usage to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOSProcessFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxOperatingSystemFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxNetworkParamsFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/software/os/linux/LinuxFileSystemFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsVirtualMemoryFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsNetworkIfFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsGlobalMemoryFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/openbsd/OpenBsdCentralProcessorFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensorsFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessorFFM.java Updates FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacVirtualMemoryFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacGlobalMemoryFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/mac/MacCentralProcessorFFM.java Updates static imports and ExceptionUtil usage to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxUsbDeviceFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxPowerSourceFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxNetworkIFFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxLogicalVolumeGroupFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxCentralProcessorFFM.java Updates static imports and FFM call wrappers to use LogLevel.
oshi-core-ffm/src/main/java/oshi/ffm/util/SysctlFFM.java Updates sysctl FFM helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/PerfDataUtilFFM.java Updates Windows perf FFM helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/IPHlpAPIUtilFFM.java Updates Windows IP helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/windows/Advapi32UtilFFM.java Updates Windows advapi helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/mac/SysctlUtilFFM.java Updates macOS sysctl FFM helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/ffm/util/platform/mac/IOKitUtilFFM.java Updates macOS IOKit helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/driver/windows/registry/HkeyUserDataFFM.java Updates registry helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/driver/mac/IOReportClientFFM.java Updates macOS IOReport helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProtocolFFM.java Updates AIX perfstat helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatProcessFFM.java Updates AIX perfstat helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatNetInterfaceFFM.java Updates AIX perfstat helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatMemoryFFM.java Updates AIX perfstat helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatDiskFFM.java Updates AIX perfstat helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatCpuFFM.java Updates AIX perfstat helper to use LogLevel.
oshi-core-ffm/src/main/java/oshi/driver/unix/aix/perfstat/PerfstatConfigFFM.java Updates AIX perfstat helper to use LogLevel.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.31579% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.43%. Comparing base (416d7d7) to head (0742db9).

Files with missing lines Patch % Lines
...os/unix/dragonflybsd/DragonFlyBsdOSProcessFFM.java 0.00% 2 Missing ⚠️
...x/dragonflybsd/DragonFlyBsdOperatingSystemFFM.java 0.00% 2 Missing ⚠️
...hi/util/platform/unix/netbsd/NetBsdSysctlUtil.java 0.00% 2 Missing ⚠️
.../software/os/unix/freebsd/FreeBsdOSProcessFFM.java 66.66% 1 Missing ⚠️
...ore/src/main/java/oshi/jna/util/SysctlUtilJNA.java 0.00% 1 Missing ⚠️
.../util/platform/unix/openbsd/OpenBsdSysctlUtil.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3525      +/-   ##
============================================
- Coverage     78.45%   78.43%   -0.03%     
- Complexity       76      195     +119     
============================================
  Files           696      697       +1     
  Lines         24100    24106       +6     
  Branches       3993     3993              
============================================
- Hits          18908    18907       -1     
- Misses         2992     2997       +5     
- Partials       2200     2202       +2     
Flag Coverage Δ
freebsd 31.13% <47.36%> (+0.02%) ⬆️
linux 35.07% <39.47%> (+0.01%) ⬆️
macos 35.99% <42.10%> (-0.03%) ⬇️
openbsd 30.32% <47.36%> (+0.01%) ⬆️
solaris 31.60% <44.73%> (+0.01%) ⬆️
windows 43.27% <52.63%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

wolfs added 2 commits July 23, 2026 12:15
LogLevel also drives direct, non-ExceptionUtil logging (SysctlUtilJNA,
PerfDataUtil, ForeignFunctions), so describe it as a general severity level
rather than specifically ExceptionUtil's swallowed-exception level.
Copilot AI review requested due to automatic review settings July 23, 2026 10:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 62 out of 62 changed files in this pull request and generated 1 comment.

Comment thread pom.xml Resolved
The verify-slf4j-17 profile did a full `clean compile` against slf4j 1.7.5,
which failed on oshi-core-ffm: unlike oshi-common/oshi-core (main at release 8,
module-info isolated in a separate release-9 execution that the profile can
skip), oshi-core-ffm compiles module-info.java in its release-25 default-compile,
where maven-compiler-plugin force-compiles it regardless of excludes. Its
`requires org.slf4j` then cannot resolve, because slf4j gained
Automatic-Module-Name only in 1.7.27.

Scope the 1.7.5 API-floor check to oshi-common and oshi-core, the classpath
modules whose module-info can be skipped and which carry the affected code.
Guard the actual oshi#3524 regression -- any reference to org.slf4j.event.Level --
across every module, including oshi-core-ffm, with forbiddenapis, which checks
by name independent of the compiled slf4j version. The verify-slf4j-17-jpms
profile still compiles the full reactor (including oshi-core-ffm's module-info)
against 1.7.27, covering JPMS resolution and SLF4J-2.0-only Logger methods there.
Copilot AI review requested due to automatic review settings July 23, 2026 10:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 63 out of 63 changed files in this pull request and generated no new comments.

@dbwiddis dbwiddis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM.

I don't think we need the pom.xml changes (and corresponding added PR test).

The additional profile and dancing around JPMS complexity adds very little value, given the forbiddenapis check.

The chances of us using any other logging features that this guards against are near-zero.

* OSHI loggable against host-provided slf4j-api versions older than 1.7.15 (e.g. the 1.7.5 bundled by Apache Maven
* 3.3.x, which loads OSHI-based extensions against its own slf4j).
*/
@ThreadSafe

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we annotate any of our enums in the codebase. If we did, Immutable would probably be a better choice here, but I think this annotation is unnecessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

wolfs added 2 commits July 23, 2026 18:48
The forbiddenapis ban on org.slf4j.event.Level already guards the oshi#3524
regression in every module, including oshi-core-ffm, so pinning the build to
1.7.5, the separate JPMS profile, and the added CI step add little value.
Restore verify-slf4j-17 to its prior form (1.7.36, guarding SLF4J-2.0-only
Logger methods). The dropped org.slf4j.event OSGi import stays dropped.
OSHI does not annotate its enums, and the enum is trivially thread-safe.
Copilot AI review requested due to automatic review settings July 23, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 62 out of 62 changed files in this pull request and generated no new comments.

@wolfs
wolfs requested a review from dbwiddis July 23, 2026 17:06
@wolfs

wolfs commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

I don't think we need the pom.xml changes (and corresponding added PR test).

Removed. Thank you for the quick review!

@dbwiddis dbwiddis linked an issue Jul 23, 2026 that may be closed by this pull request
@dbwiddis
dbwiddis merged commit 1166d60 into oshi:master Jul 23, 2026
17 checks passed
@wolfs
wolfs deleted the oshi-3524-slf4j-event-level branch July 23, 2026 19:05
dbwiddis added a commit that referenced this pull request Jul 26, 2026
PerfDataUtil.handleError and ExceptionUtil.logAtLevel each carried their
own five-way LogLevel switch. Hoist the dispatch into oshi.util.LogUtil
and have both delegate. ExceptionUtil.logAtLevel keeps its signature, so
oshi-core-ffm and any downstream caller are unaffected.

LogUtil.isEnabled restores the capability of Logger#isEnabledForLevel
that #3432 had to drop for slf4j 1.x compatibility. That lets
handleError keep skipping FormatUtil.formatError when the level is off,
without reintroducing an inline switch to do it.

handleError also double-formatted an already-formatted string:
FormatUtil.formatError returns the output of String.format, and the
result was passed through String.format again with no arguments.
PerfCounterQueryHandler had the same copy-paste, fixed there as well;
its isWarnEnabled guards are left alone, since both log at a level known
at the call site and can check it directly.

Widen the forbidden-apis ban from org.slf4j.event.Level to the whole
org.slf4j.event package. slf4j-api 1.7.5 has no such package at all, so
every type in it breaks the same hosts that motivated #3524 and #3525.

The level switch now lives in oshi-common, where a cross-platform test
covers all ten branches. Previously the only fully covered copy was in
PerfDataUtil, reachable only on Windows CI.
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.

Oshi 7.4.1 breaks network capturing with slf4j-api < 1.7.15

3 participants