Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d78628e
Bump version -> `2.0.0-SNAPSHOT.390`
alexander-yevsyukov Sep 13, 2025
48911d7
Pull more classes to `commonMain`
alexander-yevsyukov Sep 13, 2025
9a7f82b
Update dependency reports
alexander-yevsyukov Sep 13, 2025
ed40a1c
Remove unnecessary `expect/actual` arrangement
alexander-yevsyukov Sep 13, 2025
fbf76dd
Improve doc links
alexander-yevsyukov Sep 13, 2025
bd20b05
Remove `expect/actual` arrangement for the `LoggingScope` class
alexander-yevsyukov Sep 13, 2025
e0e1e58
Remove `expect/actual` arrangement for the `LogSiteLookup` object
alexander-yevsyukov Sep 13, 2025
e752091
Move `SimpleMessageFormatter` under `commonMain`
alexander-yevsyukov Sep 13, 2025
1e1ae43
Unify `LogSiteStackTrace` creation
alexander-yevsyukov Sep 13, 2025
6f88f95
Remove `expect/actual` arrangement for the `WithLogging` interface
alexander-yevsyukov Sep 13, 2025
e0c0e02
Improve var names
alexander-yevsyukov Sep 13, 2025
074ac06
Update build time
alexander-yevsyukov Sep 13, 2025
7a607f5
Make the depth increment more visible
alexander-yevsyukov Sep 13, 2025
1ab0a92
Make `RecursionDepth` platform-neutral
alexander-yevsyukov Sep 14, 2025
5aca1c5
Simplify week references in `KeyPart`
alexander-yevsyukov Sep 14, 2025
b43e702
Improve docs
alexander-yevsyukov Sep 14, 2025
3042ac3
Restore (c) header
alexander-yevsyukov Sep 14, 2025
0032936
Improve docs
alexander-yevsyukov Sep 14, 2025
e6bce74
Update build time
alexander-yevsyukov Sep 14, 2025
d8566e4
Fix (c) header
alexander-yevsyukov Sep 14, 2025
7389c7f
Update logging/src/commonMain/kotlin/io/spine/logging/util/RecursionD…
alexander-yevsyukov Sep 14, 2025
1461efc
Improve diags
alexander-yevsyukov Sep 14, 2025
dbdf097
Update build time
alexander-yevsyukov Sep 14, 2025
d335285
Undo the change suggested by Copilot
alexander-yevsyukov Sep 14, 2025
45fa164
Update build time
alexander-yevsyukov Sep 14, 2025
d275ddd
Use Kotlin class names
alexander-yevsyukov Sep 14, 2025
044fac1
Update build time
alexander-yevsyukov Sep 14, 2025
8fe2c16
Remove unnecessary `Companion` references
alexander-yevsyukov Sep 14, 2025
193f266
Update build time
alexander-yevsyukov Sep 14, 2025
23cfd88
Improve diags. of recursion depths
alexander-yevsyukov Sep 14, 2025
3d1ed4c
Update build time
alexander-yevsyukov Sep 14, 2025
22d2e32
Fix typo
alexander-yevsyukov Sep 14, 2025
716bdc1
Improve diags of `RecursionDepth`
alexander-yevsyukov Sep 14, 2025
a95e2a2
Update build time
alexander-yevsyukov Sep 14, 2025
1e27377
Backtick the display name of the test suite
alexander-yevsyukov Sep 15, 2025
e2db9c9
Update build time
alexander-yevsyukov Sep 15, 2025
1e5f0e5
Improve param docs
alexander-yevsyukov Sep 15, 2025
5fba00f
Update build time
alexander-yevsyukov Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions dependencies.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine:spine-logging-context-tests:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-context-tests:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 26.0.2.
Expand Down Expand Up @@ -413,14 +413,14 @@

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:00 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-fixtures:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-fixtures:2.0.0-SNAPSHOT.390`

## Runtime
## Compile, tests, and tooling
Expand Down Expand Up @@ -1148,14 +1148,14 @@ This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:01 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-grpc-context:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-grpc-context:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -1982,14 +1982,14 @@ This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:00 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-jul-backend:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-jul-backend:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -2800,14 +2800,14 @@ This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:00 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-jvm-default-platform:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-jvm-default-platform:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -3662,14 +3662,14 @@ This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:00 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-jvm-jul-backend-grpc-context:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-jvm-jul-backend-grpc-context:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -4520,14 +4520,14 @@ This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:01 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-jvm-jul-backend-std-context:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-jvm-jul-backend-std-context:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -5370,14 +5370,14 @@ This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:01 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-jvm-log4j2-backend-std-context:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-jvm-log4j2-backend-std-context:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -6220,14 +6220,14 @@ This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:01 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-jvm-slf4j-jdk14-backend-std-context:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-jvm-slf4j-jdk14-backend-std-context:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -7078,14 +7078,14 @@ This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:01 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-jvm-slf4j-reload4j-backend-std-context:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-jvm-slf4j-reload4j-backend-std-context:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -7940,14 +7940,14 @@ This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:01 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-log4j2-backend:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-log4j2-backend:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -8782,14 +8782,14 @@ This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:00 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging:2.0.0-SNAPSHOT.390`

## Runtime
## Compile, tests, and tooling
Expand Down Expand Up @@ -9521,14 +9521,14 @@ This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:01 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine.tools:spine-logging-testlib:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine.tools:spine-logging-testlib:2.0.0-SNAPSHOT.390`

## Runtime
## Compile, tests, and tooling
Expand Down Expand Up @@ -10256,14 +10256,14 @@ This report was generated on **Sat Sep 13 14:12:17 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:00 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-probe-backend:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-probe-backend:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.auto.service. **Name** : auto-service-annotations. **Version** : 1.1.1.
Expand Down Expand Up @@ -11122,14 +11122,14 @@ This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:00 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-smoke-test:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-smoke-test:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.18.3.
Expand Down Expand Up @@ -12008,14 +12008,14 @@ This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:00 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-logging-std-context:2.0.0-SNAPSHOT.380`
# Dependencies of `io.spine:spine-logging-std-context:2.0.0-SNAPSHOT.390`

## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
Expand Down Expand Up @@ -12826,6 +12826,6 @@ This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using

The dependencies distributed under several licenses, are used according their commercial-use-friendly license.

This report was generated on **Sat Sep 13 14:12:16 WEST 2025** using
This report was generated on **Mon Sep 15 12:08:00 WEST 2025** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ public abstract class AbstractLogger<API : LoggingApi<API>> protected constructo
if (depth.getValue() <= MAX_ALLOWED_RECURSION_DEPTH) {
backend.log(data)
} else {
reportError("unbounded recursion in log statement", data)
reportError(
"Unbounded recursion in log statement (depth: ${depth.getValue()}).", data
)
}
}
} catch (logError: RuntimeException) {
Expand Down
93 changes: 79 additions & 14 deletions logging/src/commonMain/kotlin/io/spine/logging/KeyPart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,95 @@ package io.spine.logging
* @see <a href="https://github.com/google/flogger/blob/2c7d806b08217993fea229d833a6f8b748591b45/api/src/main/java/com/google/common/flogger/LoggingScope.java#L143">
* Original Flogger code</a> for historic reference.
*/
public expect class KeyPart {
public class KeyPart private constructor(scope: LoggingScope) {

private val ref = WeakRef(scope)

/**
* The concurrency lock for accessing [onCloseHooks].
*/
private val hookLock = Any()

/**
* The list of functions to execute when the instance is [closed][close].
*/
private val onCloseHooks = mutableListOf<() -> Unit>()

/**
* Adds a hook that will be executed when this key part is closed.
*
* @param hook the function to execute on close
* Adds the function to be executed when the instance is [closed][close].
*/
@Suppress("unused") // the parameter is used by `actual` impl.
public fun addOnCloseHook(hook: () -> Unit)
public fun addOnCloseHook(hook: () -> Unit) {
synchronized(hookLock) {
onCloseHooks += hook
}
}

/**
* Closes this key part and executes all registered close hooks.
*
* After closing, the key part becomes invalid and should not be used.
* Executes clean-up functions previously added by the [addOnCloseHook] functions.
*/
public fun close()
public fun close() {
// If this were ever too "bursty" due to removal of many keys for the same scope,
// we could modify this code to process only a maximum number of removals each time
// and keep a single "in progress" `KeyPart` around until the next time.

// This executes once for each map entry created in the enclosing scope.
// It is very dependent on logging usage in the scope and theoretically unbounded.
val hooksToRun: List<() -> Unit> = synchronized(hookLock) {
// Snapshot and clear under lock to avoid concurrent modification.
val copy = onCloseHooks.toList()
onCloseHooks.clear()
copy
}
// Invoke hooks outside the lock to avoid holding the lock during the user code.
for (hook in hooksToRun) {
hook.invoke()
}
}

public companion object {

/**
* Removes keys that are no longer in use from the internal storage.
*
* This helps prevent memory leaks by cleaning up abandoned key references.
* The lock for accessing [registry].
*/
public fun removeUnusedKeys()
private val registryLock = Any()

/**
* Contains [KeyPart] instances produced by the [create] function.
*/
private val registry = mutableSetOf<KeyPart>()

public fun create(scope: LoggingScope): KeyPart =
KeyPart(scope).also { key ->
synchronized(registryLock) {
registry += key
}
}

/**
* Removes the keys that already do not have referenced scopes.
*/
public fun removeUnusedKeys() {
// There are always more specialized keys than entries in the reference queue,
// so the queue should be empty most of the time we get here.

// Snapshot the registry to avoid concurrent modification during iteration.
val snapshot: List<KeyPart> = synchronized(registryLock) {
registry.toList()
}

val dead = ArrayList<KeyPart>()
for (k in snapshot) {
if (k.ref.get() == null) {
dead += k
}
}
for (k in dead) {
// Close outside the registry lock.
k.close()
synchronized(registryLock) {
registry.remove(k)
}
}
}
}
}
Loading
Loading