lambdaisland / glogi

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

TypeError when calling log functions after advanced compilation #5

Closed vidraj closed 4 years ago

vidraj commented 4 years ago

In Glögi 1.0-47, when compiled with advanced optimizations, the logging functions throw null dereference TypeErrors. It is hard to pin down the exact source because of the minification, but I suspect that it is because the goog.log/getLogger function returns null in glogi/logger, so .logRecord is called on null in glogi/log. It used to work fine with Glögi 0.0-25 (by which I mean that there was no logging and no error).

When I set goog.debug.LOGGING_ENABLED to true, the error disappears. But curiously enough, the logs still don't show up (I would expect logging to work with this define set).

Does it behave the same way for you? Maybe I'm just doing something funny elsewhere in my program.

vidraj commented 4 years ago

This error started happening when logging was switched from using goog.log/log to calling .logRecord directly. goog.log/log contains explicit checks to prevent this. I'll send a pull request.

vidraj commented 4 years ago

When I set goog.debug.LOGGING_ENABLED to true, the error disappears. But curiously enough, the logs still don't show up (I would expect logging to work with this define set).

That was my fault, my application had the setup code, which calls glogi.console/install! and sets the levels, conditionalized on goog.DEBUG. After changing the conditional to depend on goog.debug.LOGGING_ENABLED, logging in production works as expected.