lambdaisland / glogi

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

Setting goog.debug.LogBuffer.CAPACITY fails under advanced compilation #3

Closed daveduthie closed 4 years ago

daveduthie commented 4 years ago

I've made a repro here: https://github.com/daveduthie/glogi-repro.

The stacktrace looks like this:

OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Compiling ClojureScript...
Compiling ["resources/public/js/compiled/glogi_repro.js"] from ["src"]...
Mar 13, 2020 8:41:53 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: /home/dave/src/github.com/daveduthie/glogi-repro/target/cljsbuild-compiler-1/lambdaisland/glogi/console.js:94: ERROR - @define variable goog.debug.LogBuffer.CAPACITY assignment must be global
goog.debug.LogBuffer.CAPACITY = (2);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Mar 13, 2020 8:41:53 AM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 1 error(s), 0 warning(s)
ERROR: JSC_NON_GLOBAL_DEFINE_INIT_ERROR. @define variable goog.debug.LogBuffer.CAPACITY assignment must be global at /home/dave/src/github.com/daveduthie/glogi-repro/target/cljsbuild-compiler-1/lambdaisland/glogi/console.js line 94 : 0
�[31mCompiling ["resources/public/js/compiled/glogi_repro.js"] failed.�[0m
clojure.lang.ExceptionInfo: null #:clojure.error{:phase :compilation}
    at cljs.util$compilation_error.invokeStatic(util.cljc:23)
    at cljs.util$compilation_error.invoke(util.cljc:22)
    at cljs.closure$report_failure.invokeStatic(closure.clj:418)
    at cljs.closure$report_failure.invoke(closure.clj:409)
    at cljs.closure$optimize.invokeStatic(closure.clj:1511)
    at cljs.closure$optimize.doInvoke(closure.clj:1468)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at clojure.core$apply.invoke(core.clj:660)
    at cljs.closure$build.invokeStatic(closure.clj:3054)
    at cljs.closure$build.invoke(closure.clj:2919)
    at cljs.build.api$build.invokeStatic(api.clj:208)
    at cljs.build.api$build.invoke(api.clj:189)
    at cljs.build.api$build.invokeStatic(api.clj:195)
    at cljs.build.api$build.invoke(api.clj:189)
    at cljsbuild.compiler$compile_cljs$fn__20945.invoke(compiler.clj:61)
    at cljsbuild.compiler$compile_cljs.invokeStatic(compiler.clj:60)
    at cljsbuild.compiler$compile_cljs.invoke(compiler.clj:48)
    at cljsbuild.compiler$run_compiler.invokeStatic(compiler.clj:168)
    at cljsbuild.compiler$run_compiler.invoke(compiler.clj:129)
    at user$eval21074$iter__21122__21126$fn__21127$fn__21153.invoke(form-init17343259430073162100.clj:1)
    at user$eval21074$iter__21122__21126$fn__21127.invoke(form-init17343259430073162100.clj:1)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:51)
    at clojure.lang.RT.seq(RT.java:531)
    at clojure.core$seq__5387.invokeStatic(core.clj:137)
    at clojure.core$dorun.invokeStatic(core.clj:3133)
    at clojure.core$doall.invokeStatic(core.clj:3148)
    at clojure.core$doall.invoke(core.clj:3148)
    at user$eval21074.invokeStatic(form-init17343259430073162100.clj:1)
    at user$eval21074.invoke(form-init17343259430073162100.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:7176)
    at clojure.lang.Compiler.eval(Compiler.java:7166)
    at clojure.lang.Compiler.load(Compiler.java:7635)
    at clojure.lang.Compiler.loadFile(Compiler.java:7573)
    at clojure.main$load_script.invokeStatic(main.clj:452)
    at clojure.main$init_opt.invokeStatic(main.clj:454)
    at clojure.main$init_opt.invoke(main.clj:454)
    at clojure.main$initialize.invokeStatic(main.clj:485)
    at clojure.main$null_opt.invokeStatic(main.clj:519)
    at clojure.main$null_opt.invoke(main.clj:516)
    at clojure.main$main.invokeStatic(main.clj:598)
    at clojure.main$main.doInvoke(main.clj:561)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.Var.applyTo(Var.java:705)
    at clojure.main.main(main.java:37)
Caused by: java.lang.Exception: Closure compilation failed
    ... 44 more
Subprocess failed

I've worked around this in my project by vendoring the console namespace, commenting out this line and setting goog.debug.LogBuffer.CAPACITY in the cljs compiler's :closure-defines.

plexus commented 4 years ago

Thanks for the report! This bit was an ugly but necessary hack to prevent goog.debug.Logger from turning our beautiful data structures into strings. We'll have to find a better way around this.

daveduthie commented 4 years ago

Hi @plexus and thanks for this awesome little lib!

What do you think of the workaround described above? (This is what I'm doing currently)

The README could recommend that users wanting to use lambdaisland.glogi.console/install! set goog.debug.LogBuffer.CAPACITY in their :closure-defines and this hack could be removed.

plexus commented 4 years ago

I think I've found a better solution that doesn't require the hack and doesn't need the extra :closure-defines. Would you mind giving master a spin? thanks!

daveduthie commented 4 years ago

Yes, that's fixed it. Thanks!

daveduthie commented 4 years ago

Would you mind cutting a release with this fix?

plexus commented 4 years ago

I do not:

lambdaisland/glogi {:mvn/version "0.0-29"}
[lambdaisland/glogi "0.0-29"]
daveduthie commented 4 years ago

:pray: thanks again!