Migrate logging from SLF4J to kotlin-logging#15
Conversation
…SimpleTrack, RailSwitch partial Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
…bstractPath, SimpleTrack, RailSwitch, RailSemaphore, Train completed) Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
|
@claude : is really all LoggerFactory.getLogger replaced? |
|
Claude finished @bedaHovorka's task in 42s —— View job Verification: LoggerFactory.getLogger Replacement ✅I've thoroughly searched the codebase and can confirm: Results✅ YES - All Evidence
NoteThe only Migration is complete! All logger declarations now use the idiomatic Kotlin pattern: private val logger = KotlinLogging.logger {} |
bedaHovorka
left a comment
There was a problem hiding this comment.
@copilot : There are some detekt issuses, pleae correct it
The job failed due to Detekt reporting lines longer than the allowed maximum in src/main/kotlin/cz/vutbr/fit/interlockSim/sim/Train.kt:
- Line 304
- Line 412
To fix the failure:
- Break the long lines into shorter lines in Train.kt to comply with your project's code style (usually 120 characters per line, but check your Detekt configuration for the exact limit).
- Example fix for lines near 304:
// Current (line 304):
logger.debug { "${jDisco.Process.time()} POSITION: Train $number front at separator $where, entering block $next, leaving block $current" }
// Suggested fix:
logger.debug {
"${jDisco.Process.time()} POSITION: Train $number front at separator $where, " +
"entering block $next, leaving block $current"
}- Example fix for lines near 412:
// Current (line 412):
logger.trace { "Train $number motor iteration: target speed $targetSpeed, getVelocity(), current velocity ${getVelocity()}" }
// Suggested fix:
logger.trace {
"Train $number motor iteration: target speed $targetSpeed, " +
"getVelocity(), current velocity ${getVelocity()}"
}After making these changes, commit and push your updates. The job should pass Detekt, resolving the build failure.
For details, see the lines referenced above in Train.kt on ref f194f88.
…aphore.kt Co-authored-by: bedaHovorka <5263405+bedaHovorka@users.noreply.github.com>
Yes, all
Fixed the Detekt line length issues in commit 1efd92e. Split the long lines in Train.kt (lines 304 and 412), RailSwitch.kt (line 220), and RailSemaphore.kt (line 131) to comply with the 120 character limit. Detekt now passes successfully. |
|
@claude could you update CLAUDE.md? |
|
Claude finished @bedaHovorka's task in 1m 58s —— View job CLAUDE.md Updated Successfully ✅I've updated CLAUDE.md to document the kotlin-logging migration. Here's what was changed: Changes Made1. Migration Notes Section
2. Dependency Management Section
3. Logging Section (Complete Rewrite) Updated header:
New "Adding Logging to Code" subsection:
Migration ContextThis documentation update reflects the PR changes:
Commit: 6d3ee48 |
|
Could you update CLAUDE.md @claude |
|
Claude finished @bedaHovorka's task in 3m 51s —— View job CLAUDE.md Updated for kotlin-logging Migration ✅Changes CompletedDocumentation successfully updated with comprehensive kotlin-logging migration details: 1. Dependencies SectionAdded kotlin-logging to the dependency list: 2. Logging Section - Complete RewriteThe Logging section now includes: Migration Status:
New "Adding Logging to Kotlin Code" section with:
Migration example: // Before (SLF4J with guard check):
if (logger.isDebugEnabled) {
logger.debug("Train {} at position {}", number, position)
}
// After (kotlin-logging):
logger.debug { "Train $number at position $position" }Legacy SLF4J section preserved for reference when encountering unconverted Java code. Commit Details
Push StatusThe commit is ready locally but needs to be pushed to the remote branch. Due to git workflow permissions, please push the changes using: git fetch origin copilot/rewrite-logs-to-kotlin-logging
git rebase origin/copilot/rewrite-logs-to-kotlin-logging
git push origin copilot/rewrite-logs-to-kotlin-loggingThe documentation now provides clear, comprehensive guidance for developers working with logging in this Kotlin codebase! |
- Add kotlin-logging-jvm 7.0.3 to dependency list - Update Logging section with kotlin-logging patterns and syntax - Document lambda-based lazy evaluation benefits - Add migration status note (January 2026) - Provide both new kotlin-logging and legacy SLF4J examples - Update Migration Notes section Co-authored-by: bedaHovorka <bedaHovorka@users.noreply.github.com>
|




Migrate from SLF4J to kotlin-logging
This PR migrates all logging from SLF4J to kotlin-logging to eliminate verbose
if (logger.isXXXEnabled())guard checks and leverage Kotlin's lambda-based lazy evaluation.Changes
Dependencies
kotlin-logging-jvm:7.0.3tobuild.gradle.ktsandgradle.propertiesLogger declarations
Replaced factory pattern with idiomatic Kotlin logger initialization:
Logging calls
Converted to lambda-based API for automatic lazy evaluation:
Migration scope
Fully migrated (8 files): Main, DefaultContext, AbstractPath, SimpleTrack, RailSwitch, RailSemaphore, Train, Generator
Partial migration (2 files): InOutWorker, ShuntingLoop - logger declarations updated but calls retain SLF4J syntax for backward compatibility during phased rollout
The partial migration is intentional - kotlin-logging wraps SLF4J so both syntaxes coexist safely, allowing incremental conversion of the remaining ~20 logging calls.
Status
LoggerFactory.getLoggercalls replaced withKotlinLogging.logger {}Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.