Open empperi opened 5 years ago
prehook already exists and is working for this usecase: https://figwheel.org/config-options#pre-build-hooks
I think this can be closed.
@antonmos that is documented to run before the CLJS compilation, ie:
A collection of symbol or strings that represent Clojure functions to call just before your ClojureScript sources get built.
Saying that it solves the issue means we would need to imply that the Jetty server doesn't get started before the CLJS compilation and therefore possibly before this pre-build-hook.
This may be the case, but if so, that would be nice to be made clearer in the doc then.
When using Figwheel Main with Leiningen in a project with Timbre and it's slf4j-adapter one gets a ton of unnecessary logging from Jetty used by Figwheel Main.
This is caused by SLF4J and how it works. SLF4J searches the classpath for implementations during classload time and picks one into use. Now since if one adds the sfl4j-adapter for Timbre into classpath it gets loaded and taken into use. Timbre on the other hand defaults to logging everything at
:debug
level unless otherwise specified. Timbre doesn't provide a way to give it a configuration file which it would magically load during startup (which is a good thing!) but instead opts in for declarative configuration. Now, however when executing Figwheel Main via Leiningen aliases one doesn't have a way to step in between and execute a simple Timbre initialization command to provide the logging configurations (and thus silence all Jetty logging). Also, Figwheel Main logging level configurations do not affect Jetty, it only affects Figwheel Main's own logging. Also prebuild hooks are apparently executed before actual build, not before tests or they are executed in a separate JVM instance.The end result of all this is that when executing a simple test run with only client side test logic (no backend calls etc) this causes over 20 000 lines of logging to appear done by Jetty. As it is now I have following workarounds for this problem:
TIMBRE_LEVEL
environment variable before executing the build. This is however a bad solution since it is totally environment dependent and would require extra setup steps for each and every environment.uberjar
profile dependencies. This way one gets the adapter into place when creating a final artifact but it won't be in use otherwise. This too isn't that great solution since now one doesn't see any logging done by possible libraries via SLF4J when doing development. This also causes a warning to appear by SLF4J since there are no implementations loaded and Jetty tries to do it's logging to it.I'm currently going with the last workaround but I would want to see a real solution to this problem. And that would simply be:
Provide a prehook functionality which will be executed before Figwheel Main does anything but that it will be executed in the same JVM as where the Jetty will be. This way one can do whatever setup one needs and during that can also silence the Jetty SLF4J logger.