touchlab / Kermit

Kermit by Touchlab is a Kotlin Multiplatform centralized logging utility.
https://kermit.touchlab.co
Apache License 2.0
699 stars 40 forks source link

Support for the new kotlin WASM target #362

Closed Ic-ks closed 11 months ago

Ic-ks commented 1 year ago

Hi, Jetbrains started to provide library versions of ktor, kotlinx.serialization and some other libraries for the already available wasm target:

kotlin {
// ...
    @Suppress("OPT_IN_USAGE")
    wasm {
        browser()
    }
}

It would be nice if kermit could support the wasm target, too.

BTW thanks for this library. Great work!

kpgalligan commented 1 year ago

Yeah, I think it's time. I don't know off hand, does console work the same in WASM?

Ic-ks commented 1 year ago

I also hoped that it comes with the same console, but it didn't. I think the background is that a wasm can be executed outside of a browser. I could workaround it by declaring the console again. I forked the project, here are the changes I did to support at least wasm { browser() }. If you want, I can create a pull request?

I think for wasms which are not executed in a browser, there are still some things to do. I discovered following maybe related code in the generated example.uninstantiated.mjs of my wasm example project:

            if (isBrowser) {
                console.error(text, ...styles);
            } else {
                const t = "\n" + text;
                if (typeof console !== "undefined" && console.log !== void 0)
                    console.log(t);
                else
                    print(t);
            }

Nevertheless wasm is still experimental so I think in the future they will provide a proper logging interface and logic to differ between a browser wasm and any other wasm is forgiven effort.

HoffiMuc commented 11 months ago

any idea on a new release date supporting wasm ?

sunildhiman90 commented 9 months ago

@kpgalligan So does it support wasm now or its still in planning phase? Or If its in progress, any idea when release will be availabe with wasm support?

HoffiMuc commented 9 months ago

it does, yes.

sunildhiman90 commented 9 months ago

thanx @HoffiMuc