lambdaisland / glogi

A ClojureScript logging library based on goog.log
Mozilla Public License 2.0
119 stars 13 forks source link

SLF4J errors in "pure CLJS" project #25

Closed rome-user closed 1 year ago

rome-user commented 1 year ago

Hello.

I am using glogi version 1.2.164 with shadow-cljs 2.20.14. When I use glogi in my CLJS code, everything works as expected. However on startup I will get the following message in my REPL.

[:app] Configuring build.
[:app] Compiling ...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.

Importing the dependency [org.slf4j/slf4j-nop "2.0.6"] fixes this issue. I don't know why SLF4J is being used at all if my project has zero Clojure source files and I only use glogi within ClojureScript.

alysbrooks commented 1 year ago

Hmm, I don't think glogi should pull in SLFJ unless you include Pedestal. But I'm guessing you don't have any other logging dependencies, including Pedestal?

Are you using deps.edn? You can use clojure -Stree to see where dependencies are coming from.

alysbrooks commented 1 year ago

Oh sorry, looks like you're using Leiningen by the looks of it. lein deps :tree is the equivalent.

rome-user commented 1 year ago

I'm using shadow-cljs without Leiningen or deps.edn. I decided to print my dependency tree. This seems to be culprit

[io.methvin/directory-watcher "0.17.1"]
  [net.java.dev.jna/jna "5.12.1"]
  [org.slf4j/slf4j-api "1.7.36"]

What I find strange is how I don't get the SLF4J logging errors unless I decide to make use of Glogi. Nothing seems to be depending on pedestal.

alysbrooks commented 1 year ago

Hmm, I'm honestly a bit stumped why it would do that. We use io.methvin/directory-watcher in Kaocha, but Kaocha isn't one of Glögi's dependencies. (We use Kaocha to test Glögi, but unless I'm missing something, it shouldn't be pulled in as a dependency when you're just using Glögi.)

I don't think leaving the error in place or importing [org.slf4j/slf4j-nop "2.0.6"] should affect your CLJS builds in any way although I guess it might make them a tiny bit slower. (If I'm missing something, definitely let me know!) I would like to avoid extraneous warnings/error messages because I dislike when the libraries I use do that. :)

rome-user commented 1 year ago

Since some time has passed and the workaround of including [org.slf4j/slf4j-nop "2.0.6"] gets rid of the error, I will close this issue for now.