Skip to content

ADFA-4238: use custom Logger for Kotlin compiler#1378

Merged
itsaky-adfa merged 6 commits into
stagefrom
fix/ADFA-4238
Jun 24, 2026
Merged

ADFA-4238: use custom Logger for Kotlin compiler#1378
itsaky-adfa merged 6 commits into
stagefrom
fix/ADFA-4238

Conversation

@itsaky-adfa

@itsaky-adfa itsaky-adfa commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

See ADFA-4238 for more details.

Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
@itsaky-adfa itsaky-adfa requested a review from a team June 8, 2026 18:32
@itsaky-adfa itsaky-adfa self-assigned this Jun 8, 2026
@coderabbitai

coderabbitai Bot commented Jun 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dfd54042-3cc9-4e99-9845-2163247cfc73

📥 Commits

Reviewing files that changed from the base of the PR and between b38ce78 and 821a9f3.

📒 Files selected for processing (2)
  • lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/CompilationEnvironment.kt
  • lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/compiler/util/SLF4JLoggerTest.kt

📝 Walkthrough
  • Switched the Kotlin compiler logging setup to use a custom SLF4JLogger, wiring Logger factory initialization to SLF4J-backed output.

  • Reworked shutdown timeout handling to use a duration-based constant (2.seconds) instead of a millisecond Long.

  • Added SLF4JLogger, an adapter that maps IntelliJ/Kotlin logger calls to SLF4J, including debug/info/warn/error handling and throwable support.

  • Added regression tests to confirm the compiler logger factory returns SLF4JLogger and that error(...) calls do not throw.

  • Risk / best-practice note: the new logger adapter includes custom formatting logic for error(...), so behavior may differ from the default IntelliJ logger in edge cases; logging output should be validated carefully.

  • Risk / best-practice note: overriding the global logger factory at initialization time can have broader side effects if other components expect the default Kotlin/IntelliJ logger implementation.

Walkthrough

A new SLF4JLogger adapts IntelliJ logger calls to SLF4J. AbstractCompilationEnvironment now installs that logger factory and uses a duration-based close timeout, and CompilationEnvironment switches to the same timeout constant. Tests cover logger factory selection and error logging.

Changes

SLF4J Logger Bridge

Layer / File(s) Summary
SLF4JLogger implementation
lsp/kotlin/.../compiler/util/SLF4JLogger.kt
New Logger adapter forwards debug, info, warn, and error calls to SLF4J with throwable-aware overload selection and composed error messages.
Factory registration and timeout wiring
lsp/kotlin/.../compiler/AbstractCompilationEnvironment.kt, lsp/kotlin/.../compiler/CompilationEnvironment.kt
Updates imports, sets Logger's factory to SLF4JLogger, replaces the millisecond close-drain constant with CLOSE_DRAIN_TIMEOUT = 2.seconds, and uses that duration in both close() methods.
Logger factory and error tests
lsp/kotlin/.../compiler/util/SLF4JLoggerTest.kt
Adds tests asserting the Kotlin compiler logger factory returns SLF4JLogger and that error(...) overloads do not throw.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • dara-abijo-adfa
  • Daniel-ADFA

Poem

🐇 A logger hops from one bridge to the next,
SLF4J sings while the Kotlin code flexed.
Two seconds for closing, a tidy new rhyme,
This bunny approves of the logging design.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title clearly summarizes the main change: introducing a custom logger for the Kotlin compiler.
Description check ✅ Passed The description is related to the changeset by pointing to the linked ADFA-4238 ticket.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ADFA-4238

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/AbstractCompilationEnvironment.kt`:
- Around line 104-105: The CLOSE_DRAIN_TIMEOUT constant in
AbstractCompilationEnvironment.kt is set to 2 milliseconds, which is too short
for the drain operation to complete successfully during shutdown. Increase the
CLOSE_DRAIN_TIMEOUT value from 2.milliseconds to a more reasonable duration that
allows sufficient time for background index workers to drain before disposal
(the suggested fix section indicates this should be a longer timeout). Also
check line 352 in the same file for a similar timeout value that needs the same
adjustment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 64289dbd-ce0b-48a4-a8b3-c8f3462097f2

📥 Commits

Reviewing files that changed from the base of the PR and between 8917fca and 2138dc8.

📒 Files selected for processing (2)
  • lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/AbstractCompilationEnvironment.kt
  • lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/util/SLF4JLogger.kt

Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
@itsaky-adfa itsaky-adfa merged commit 2387b73 into stage Jun 24, 2026
2 checks passed
@itsaky-adfa itsaky-adfa deleted the fix/ADFA-4238 branch June 24, 2026 14:26
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.

4 participants