This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-10
Channels
- # aleph (1)
- # announcements (21)
- # babashka (3)
- # beginners (98)
- # calva (2)
- # circleci (3)
- # clara (58)
- # clj-kondo (123)
- # cljs-dev (1)
- # cljsrn (7)
- # clojure (162)
- # clojure-europe (2)
- # clojure-finland (7)
- # clojure-italy (5)
- # clojure-nl (6)
- # clojure-sanfrancisco (1)
- # clojure-spec (1)
- # clojure-survey (17)
- # clojure-uk (70)
- # clojuredesign-podcast (2)
- # clojurescript (46)
- # cloverage (5)
- # cursive (2)
- # data-science (22)
- # datascript (1)
- # datomic (60)
- # emacs (3)
- # figwheel-main (1)
- # fulcro (26)
- # graalvm (5)
- # jackdaw (3)
- # leiningen (8)
- # luminus (1)
- # off-topic (8)
- # other-lisps (2)
- # pedestal (27)
- # re-frame (17)
- # reagent (20)
- # reitit (3)
- # shadow-cljs (37)
- # spacemacs (23)
- # sql (69)
- # tools-deps (2)
- # utah-clojurians (9)
- # xtdb (3)
Q about io.pedestal.log; I believe this line of code:
https://github.com/pedestal/pedestal/blob/master/log/src/io/pedestal/log.clj#L247
may be broken. It attempts to use the override-logger
as a LoggerSource instance, rather than a function that is passed a string and returns a LoggerSource.
Unless I'm missing something, you can't currently use
-Dio.pedestal.log.overrideLogger=my.namespace/create-logger-source
because you get a runtime exception trying to apply the LoggerSource protocol to a Var.
Am I missing something?My scenario is to redirect code writing to io.pedestal.log/log to instead invoke our legacy, in-house logging framework.
I believe the overrideLogger
system property works when used w/ log/info, log/debug, etc., as they go through the private log-expr function:
https://github.com/pedestal/pedestal/blob/master/log/src/io/pedestal/log.clj#L275
... which does what you'd expect; treat the override-logger as a function that generates LoggerSource instances.
Because my defaultLogger function needs to require io.pedestal.log so that it can implement the LoggerSource protocol.
But https://github.com/pedestal/pedestal/blob/621b6896aab6582499e0076bd9c73d5aeb01dae9/log/src/io/pedestal/log.clj#L196 needs the Var in question to resolvable when io.pedestal.log is loading, resulting in a loop.
@hlship here’s one way to address that. I’ll be honest, I’d rather the protocol live in a separate ns but unfortunately that’s not how it was implemented. This method of overriding is also used for tracing and has been a source of confusion as well. I’m going to chat with Paul about it.
Fortunately, override-logger
is public, so I can just alter-var-root it in my server startup code, which should catch most of what I need.
Ok. I’ll work on clarifying how this is intended to be done in the docs. It’s come up a number of times.
I could work on a PR that made use of a delay, but it's problematic because override-logger is public.
Then again, it seems like no one could possibly be using it via the sysprop/envvar at all.
FWIW, spoke to Paul and he stated that what I posted is the intended setup, albeit other methods could work as well.
It just feels a bit broken in a way that's all but impossible to fix in a backwards compatible way. Logging ... it'll always bite your ass.
Is there a way to move it to a new namespace but alias the protocol (and protocol methods) back into io.pedestal.log?