Uploaded image for project: 'ClojureScript'
  1. CLJS-2930

logging via goog.log not visible for optimizations other than none

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: 1.10.238
    • Fix versions: None
    • Labels:
    • Environment:

      node: v10.10.0
      clj: 1.9.0.391
      cljs: v1.10.338 (and sha "6eedd0a08c49f7b0d4dcb30977b2fb38c90577bd")

      Description

      steps to reproduce

      Given

      deps.edn
      {:paths
       ["."]
      
       :deps
       {org.clojure/clojurescript {:mvn/version "1.10.339"
                                   #_#_:git/url "https://github.com/clojure/clojurescript.git"
                                   #_#_:sha "6eedd0a08c49f7b0d4dcb30977b2fb38c90577bd"}}}
      
      foo.cljs
      (ns foo
        (:require [goog.log :as glog])
        (:import goog.debug.Console))
      
      (def logger
        (glog/getLogger "app"))
      
      (def console (goog.debug.Console.))
      
      (defn workaround! []
        (.setConsole goog.debug.Console js/console))
      
      
      (defn -main [& args]
        (.setCapturing console true)
        (.setLevel logger goog.debug.Logger.Level.FINEST)
      
        (when args
          (workaround!))
        (glog/error logger "some error"))
      
      (set! *main-cli-fn* -main)
      

      When I compile with optimization `none` and run, logging does appear:

      $ clj -m cljs.main -v -O none -t node -c foo
      $ node out/main.js
       [  0.002s] [app] some error
      

      When I compile with optimization `simple` (or `advanced`) and run, logging does not appear.

      Expected: optimization simple should have no effect on appearance of logging on Node (just like when compiling for the browser).

      various (FWIW)

      With simple, `goog.debug.Console.console_` ends up being nil as `goog.global['console']` is nil (https://github.com/google/closure-library/blob/master/closure/goog/debug/console.js#L169).

      `println` works in both none and simple.

      When targetting browser both none and simple show logging.

      A workaround is to setConsole: `(.setConsole goog.debug.Console js/console)`

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: