oliyh / re-graph

A graphql client for clojurescript and clojure
460 stars 39 forks source link

Clojurescript 1.10.844 support #82

Closed crofty closed 3 years ago

crofty commented 3 years ago

Unfortunately the version of Google Closure used by Clojurescript 1.10.844 has breaking changes to logging, as described here: https://clojurescript.org/news/2021-04-06-release.

This affects this part of re-graph: https://github.com/oliyh/re-graph/blob/master/src/re_graph/logging.cljc#L9-L18

Leading to these warnings:


[2021-04-07T09:27:13Z] [Figwheel:WARNING] Compile Warning   resources/public/js/prod/out/re_graph/logging.cljc   line:9  column:6
--
  | [2021-04-07T09:27:13Z]
  | [2021-04-07T09:27:13Z]   Wrong number of args (1) passed to goog.log/getLogger
  | [2021-04-07T09:27:13Z]
  | [2021-04-07T09:27:13Z]    4    (:require #?(:clj  [clojure.tools.logging :as log]
  | [2021-04-07T09:27:13Z]    5                 :cljs [goog.log :as glog])))
  | [2021-04-07T09:27:13Z]    6
  | [2021-04-07T09:27:13Z]    7  #?(:cljs
  | [2021-04-07T09:27:13Z]    8     (def logger
  | [2021-04-07T09:27:13Z]    9       (glog/getLogger "app")))
  | [2021-04-07T09:27:13Z]            ^---
  | [2021-04-07T09:27:13Z]   10
  | [2021-04-07T09:27:13Z]   11  #?(:cljs
  | [2021-04-07T09:27:13Z]   12     (def levels {:severe goog.debug.Logger.Level.SEVERE
  | [2021-04-07T09:27:13Z]   13                  :warning goog.debug.Logger.Level.WARNING
  | [2021-04-07T09:27:13Z]   14                  :info goog.debug.Logger.Level.INFO
  | [2021-04-07T09:27:13Z]
  | [2021-04-07T09:27:13Z] [Figwheel:WARNING] Compile Warning: Wrong number of args (2) passed to goog.log/info  resources/public/js/prod/out/re_graph/logging.cljc   line:34  column:14
  | [2021-04-07T09:27:13Z] [Figwheel:WARNING] Compile Warning: Wrong number of args (2) passed to goog.log/fine  resources/public/js/prod/out/re_graph/logging.cljc   line:39  column:14
  | [2021-04-07T09:27:13Z] [Figwheel:WARNING] Compile Warning: Wrong number of args (2) passed to goog.log/warning  resources/public/js/prod/out/re_graph/logging.cljc   line:44  column:14
  | [2021-04-07T09:27:13Z] [Figwheel:WARNING] Compile Warning: Wrong number of args (2) passed to goog.log/error  resources/public/js/prod/out/re_graph/logging.cljc   line:49  column:14

I'd take a stab at fixing it, but i'm unsure what the approach needs to be to make this work with both the previous and current versions of Google Closure.

oliyh commented 3 years ago

Hi,

Thanks for reporting this, I'll have to see what flags are exposed by the compiler and see if there's a way to optionally require/define.

Cheers

oliyh commented 3 years ago

From #clojurescript on slack:

oliy Today at 14:46 hello, does anyone know if there a way to detect the compiler version (or closure version) and branch code depending on that? i'm trying to work out how to cope with the changes to closure in the latest release in a backwards compatible way, namely decide whether to use goog.debug.Logger.Level.SEVERE or goog.Logger.Level.SEVERE

3 replies

rakyi 2 hours ago without knowing the cljs/closure compiler specifics, I’d assume (exists? goog.Logger) could be one way to find out if you are on the newer version

nilern 1 hour ago That is probably more robust than reading the version anyway.

oliy < 1 minute ago ah perfect, thank you i didn't know about exists? . it looks to be exactly what i want

oliyh commented 3 years ago

Hi,

This should be fixed in the latest 0.1.16-SNAPSHOT with a slight change to the signature of the re-graph.logging/set-level! cljs fn

Thanks,

crofty commented 3 years ago

Awesome, thank you!

daveduthie commented 2 years ago

Hi @oliyh,

would you consider releasing 0.1.16?

oliyh commented 2 years ago

Hi @daveduthie it's now released

daveduthie commented 2 years ago

Awesome, thanks!