Skip to content

More common code#131

Merged
alexander-yevsyukov merged 38 commits intomasterfrom
more-common-code
Sep 15, 2025
Merged

More common code#131
alexander-yevsyukov merged 38 commits intomasterfrom
more-common-code

Conversation

@alexander-yevsyukov
Copy link
Contributor

@alexander-yevsyukov alexander-yevsyukov commented Sep 13, 2025

This PR continues making the logging module more platform-neutral. The details are covered by the sections below.

Classes moved under commonMain

  • CountingRateLimiter
  • DurationRateLimiter
  • LogContext
  • LogSiteGroupingKey
  • RateLimitingPeriod
  • RateLimitStatus
  • SamplingRateLimiter

Other notable changes

  • The ReqursionDepth class was reworked narrowing down the expect/actual to the newly introduced WeekRef class. So, now the ReqursionDepth class class uses the CouroutineContext key Kotlin's feature, which is platform neutral.
  • The LoggingScope, LogPerBucketingStrategy, classes, and LogSiteLookup object were reworked to avoid unnecessary expect/ actual arrngament.
  • Added expect/actual fun stackForCallerOf() to make the created stack trace platform-neutral.
  • Removed expect/actual arrangement for the WithLogging interface as no longer necessary.
  • Removed expect/actual arrrangement for the LoggingScope class as no longer necessary.
  • Removed expect/actual arrrangement for the LogPerBucketingStrategy class as no longer necessary.

@alexander-yevsyukov alexander-yevsyukov self-assigned this Sep 13, 2025
@alexander-yevsyukov alexander-yevsyukov marked this pull request as draft September 13, 2025 18:47
@codecov
Copy link

codecov bot commented Sep 13, 2025

Codecov Report

❌ Patch coverage is 0% with 119 lines in your changes missing coverage. Please review.
✅ Project coverage is 14.59%. Comparing base (6027baf) to head (5fba00f).
⚠️ Report is 39 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #131      +/-   ##
============================================
- Coverage     15.24%   14.59%   -0.65%     
  Complexity      147      147              
============================================
  Files            96      103       +7     
  Lines          2617     2733     +116     
  Branches        365      380      +15     
============================================
  Hits            399      399              
- Misses         2188     2304     +116     
  Partials         30       30              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexander-yevsyukov alexander-yevsyukov changed the title more-common-code More common code Sep 14, 2025
Copy link
Contributor

Copilot AI left a comment

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 bumps the version from 2.0.0-SNAPSHOT.380 to 2.0.0-SNAPSHOT.390 and introduces significant architectural improvements to the logging library's multi-platform design. The changes move from platform-specific expect/actual declarations to common implementations with platform-specific details where needed, improving code reuse and maintainability.

Key changes include:

  • Consolidation of logging scope and recursion depth management into common code using coroutine contexts
  • Refactoring of weak reference handling and stack trace utilities to use shared implementations
  • Simplification of the logging API by removing platform-specific abstractions

Reviewed Changes

Copilot reviewed 24 out of 31 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
version.gradle.kts, pom.xml Version bump to 2.0.0-SNAPSHOT.390
logging/src/commonMain/kotlin/io/spine/logging/util/RecursionDepth.kt Moved from expect/actual to common implementation using CoroutineContext
logging/src/commonMain/kotlin/io/spine/logging/WithLogging.kt Changed from expect interface to common interface with default implementation
logging/src/commonMain/kotlin/io/spine/logging/WeakRef.kt Refactored from WithLogging to WeakRef with platform-agnostic API
logging/src/commonMain/kotlin/io/spine/logging/LoggingScope.kt Moved from expect/actual to common abstract class with concrete implementation
logging/src/commonMain/kotlin/io/spine/logging/KeyPart.kt Converted from expect/actual to common implementation
logging/src/jvmMain/kotlin/io/spine/logging/WeakRef.kt JVM-specific implementation using Java WeakReference
logging/src/jvmMain/kotlin/io/spine/logging/LoggingFactory.kt Variable renaming for clarity

alexander-yevsyukov and others added 8 commits September 14, 2025 18:57
…epth.kt


Fix guarding overflow

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The change was incorrect because the code guards against going the depth below zero. When the recursion depth becomes zero the context should be freed: see `close()` on this.

When we encounter a depth instance which is `-1` it's the error we should report.
@alexander-yevsyukov alexander-yevsyukov marked this pull request as ready for review September 14, 2025 18:28
Copy link
Contributor

Copilot AI left a comment

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 25 out of 32 changed files in this pull request and generated 6 comments.

Copy link
Contributor

Copilot AI left a comment

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 25 out of 32 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

logging/src/commonMain/kotlin/io/spine/logging/WeakRef.kt:1

  • There's a typo in the documentation comment. 'WeekRef' should be 'WeakRef'.
/*

Copy link
Contributor

Copilot AI left a comment

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 25 out of 32 changed files in this pull request and generated 4 comments.

Copy link
Contributor

Copilot AI left a comment

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 25 out of 32 changed files in this pull request and generated 1 comment.

@alexander-yevsyukov alexander-yevsyukov merged commit 79f4563 into master Sep 15, 2025
7 checks passed
@alexander-yevsyukov alexander-yevsyukov deleted the more-common-code branch September 15, 2025 11:13
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.

3 participants