https://kotlinlang.org logo
#compose-web
Title
# compose-web
c

Chris

11/21/2023, 4:08 AM
Hi folks! I have a logging question 😅 I’m using Kotlin/JS with Compose for HTML. I’m running a local web server with
gradle run --continuous
so I can debug locally. (I’m not sure which local web server this actually spins up; it’s just the default one.) With my setup, I don’t have access to the JavaScript console on the client side. (VR development FTW!) Instead, I’d love to send a page request to the web server, like
http://localhost:8080/log?value=This%20is%20logging
and just have the default web server log the request to the command line. That’s one way I can think to get ‘logs’ showing up on my Mac without much fuss. Alternatively, I could have some other local web service on another port that handles log requests, like
python -m http.server 3000
. What do you think? Are there easy options here, or should I try to figure out Android
logcat
again for embedded web views?
e

ephemient

11/21/2023, 4:21 AM
if you're talking about the meta quest, I'd expect webviews to be debuggable via normal android mechanisms, https://developer.chrome.com/docs/devtools/remote-debugging/
c

Chris

11/21/2023, 4:36 AM
Oh, interesting! I didn’t know about that. Thanks! I’m not sure if it’ll work with embedded web views, but I’ll give it a shot. (And yes, I’ve got an Android app wrapping a web view on Meta Quest! So not the most straightforward setup unfortunately.)
e

ephemient

11/21/2023, 4:38 AM
if you have ADB then it'll work as long as your app is debuggable or if you call https://developer.android.com/reference/android/webkit/WebView#setWebContentsDebuggingEnabled(boolean) somewhere in your code
🙌 1
d

David Herman

11/21/2023, 9:49 PM
You might be interested in my project, #kobweb (https://github.com/varabyte/kobweb). It runs a custom ktor server for you, which you can extend with something called API routes. It would be pretty trivial to send a message from the client to the server and have the server log it. It may be overkill for your case though -- it sounds like you don't need a site as much as you need a page? But otherwise, Kobweb is good for providing built-in live reloading behavior as well as easy setup to get a fullstack project going if that's what you need.
❤️ 1
I had a moment so I threw together a minimal example of having a client send a message to the server using Kobweb. I basically used the empty project template and added the following code: https://github.com/bitspittle/log-demo/commit/5742da750ecf7bec406bf64fba9e7a65f7a56f2b
No pressure of course, but if you wanted to try this yourself... • Install the Kobweb CLI • git clone https://github.com/bitspittle/log-demo • cd log-demo/site • kobweb run And after running the site and sending some logs, you can see them in
log-demo/site/.kobweb/site/server/logs/kobweb-server.log
c

Chris

11/22/2023, 2:38 AM
Oh, that’s awesome – thanks, David! I had a good look at Kobweb’s modifier system when I spun up my own project, which also uses custom modifiers to generate HTML. It was a great inspiration!
(I’d love to chat and share more about what I’m doing sometime, actually, if you’re interested! I just wrapped at Apple after 5 years on the Vision Pro and I’m diving in to Kotlin now.)
d

David Herman

11/22/2023, 2:41 AM
I'll DM you shortly!
3 Views