Skip to content

Conversation

oshai
Copy link
Owner

@oshai oshai commented Aug 12, 2025

Summary Adds WebAssembly WASI (wasmWasi) target to kotlin-logging, reusing directMain logic and providing a simple console appender.

Motivation Enable kotlin-logging usage in WASI runtimes (e.g. wasmtime, Node.js WASI, future serverless/Wasm hosts) with minimal setup, consistent with existing wasmJs and native behavior.

Key Changes

Gradle: added wasmWasi target (with nodejs() environment) + source sets (wasmWasiMain / wasmWasiTest).
New actuals for wasmWasi:
KotlinLoggingConfiguration (simple mutable properties)
ConsoleOutputAppender (stdout println for all levels except OFF)
KLoggerNameResolver (mirrors wasmJs stacktrace-based resolver)
Tests: SimpleWasmWasiTest (basic logging + OFF level check)
Changelog: unreleased note about wasmWasi support.

Design Notes

Uses println (no stderr separation; WASI stderr mapping can be added later if needed).
Reuses directMain API surface; no public API changes.
Keeps implementation minimal to reduce maintenance burden.
Node.js runtime declared to satisfy current Gradle/WASM DSL expectations.
Testing

Compiled wasmWasi main & tests (compileKotlinWasmWasi / compileTestKotlinWasmWasi succeeded).
Did not run full build due to missing Android SDK in current environment (pre-existing constraint).
Logic mirrors existing wasmJs test patterns minus JS console interception.
Backward Compatibility

No breaking changes; new target only.
Existing platforms unaffected.

@oshai oshai requested a review from Copilot August 12, 2025 14:12
Copy link

@Copilot 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 adds WebAssembly WASI (wasmWasi) target support to kotlin-logging, enabling the library to work in WASI runtimes like wasmtime and Node.js WASI with minimal setup.

  • Introduces wasmWasi target with console-based logging output
  • Implements required actual classes for the new target (configuration, appender, name resolver)
  • Adds comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/wasmWasiMain/kotlin/io/github/oshai/kotlinlogging/KotlinLoggingConfiguration.kt Provides wasmWasi-specific logging configuration with default settings
src/wasmWasiMain/kotlin/io/github/oshai/kotlinlogging/ConsoleOutputAppender.kt Implements console output appender using stdout println for WASI target
src/wasmWasiMain/kotlin/io/github/oshai/kotlinlogging/internal/KLoggerNameResolver.kt Provides stacktrace-based logger name resolution mirroring wasmJs implementation
src/wasmWasiTest/kotlin/io/github/oshai/kotlinlogging/SimpleWasmWasiTest.kt Comprehensive test suite covering basic logging functionality and configuration
ChangeLog.md Documents the addition of wasmWasi target support

@oshai oshai force-pushed the feature/wasm-wasi-support branch from 89c8282 to 402ca15 Compare August 18, 2025 18:00
@oshai oshai merged commit be2e531 into master Aug 19, 2025
9 checks passed
@oshai oshai deleted the feature/wasm-wasi-support branch August 19, 2025 10:54
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.

1 participant