Log4s / log4s

High-performance SLF4J wrapper for Scala.
Other
171 stars 25 forks source link

Scala.js support #17

Closed cquiroz closed 6 years ago

cquiroz commented 7 years ago

Is there any possibility to support Scala.js. Given that slf4j won't be moved to scala.js anytime soon perhaps log4s would need to have a simple implementation of the public API for scala.js

I'd like to be able to use it on https://github.com/http4s/http4s/issues/956

sarahgerweck commented 7 years ago

Hi @cquiroz. I hadn't really thought about this until now. When I wrote Log4s, the design was "SLF4J is a great solution to flexible Java logging, but it would be nice if it could better leverage some of Scala's features."

Do you have any particular logging solutions for scala.js that you'd like to see supported? I haven't had occasion to do a lot of scala.js, but I've seen scala-js-java-logging.

I don't particularly want to grow Log4s into an entire logging solution that includes formatters, appenders, filters, and so on. However, I'm not at all opposed to enhancing Log4s so that it can support such a project.

I'm thinking that the right way to do this might be to actually fork out an "SL4JS" so Scala developers can use the SLF4J APIs with drop-in scala.js logging libraries.

cquiroz commented 7 years ago

The reason I'm interested on this is because http4s uses log4s and I'm attempting to port it to scala.js. Changing framework on http4s maybe hard. I'm thinking that the api of log4s could be re implemented without slf4j to just provide what http4s needs.

On the client side you have normally little need for complex configuration and nonetheless you can't really switch backends easily since there is no reflection

I'll try to implement a minimal API to get me there and submit it for consideration when completed

sarahgerweck commented 7 years ago

@cquiroz would something like scala-js-java-logging work for your use case? It seems to be the most standard thing out there right now for logging in scala.js.

cquiroz commented 7 years ago

Maybe that's an option if we can change http4s to switch

sarahgerweck commented 7 years ago

What I mean is that if I had a build of Log4s so that it could do its logging using scala-js-java-logging, would that be suitable? Or does http4s have its own internal logging system that you want to use?

cquiroz commented 7 years ago

Right, that would do I think

oyvindberg commented 6 years ago

Did you ever progress with this, @cquiroz ?

cquiroz commented 6 years ago

@oyvindberg Not really. I added stubs for log4s in http4s

sarahgerweck commented 6 years ago

@oyvindberg is there a particular logging framework that you're using as a replacement for slf4j/logback when you're working in scala.js? I have been kicking around some potential solutions to solve this (and #20), but would be interested in exactly what you're hoping to do here.

sarahgerweck commented 6 years ago

Log4s 1.6 has fairly comprehensive Scala.js support, including the ability to configure logging thresholds and appenders just as you would have with Logback or Log4j. (The flexibility is not as sophisticated as those frameworks, but it's good enough for typical JavaScript purposes and fairly extensible.)

cquiroz commented 6 years ago

That's great, thanks a lot!

oyvindberg commented 6 years ago

Awesome!

sarahgerweck commented 6 years ago

@cquiroz & @oyvindberg if either of you end up trying out Scala.js support, I'd be very interested in any feedback or issues you encounter. Scala.js support is still experimental in that the configuration and JS-native APIs might change, but I think it's ready to start using. There's a fair amount of docs in the README, though I don't have Scaladocs hosted yet.