Fork me on GitHub
#duct
<
2019-09-22
>
bocaj04:09:53

How do ya’ll do logging for your own code in duct? I see passing a logger as config to jetty server, for example, but what about your own stuff? Too heavy weight to pass in a logger, or is it worth the trouble.

iarenaza19:09:50

We pass in the logger and use duct logging machinery (which uses timbre by default)

4
bocaj05:09:35

Good to know, will continue on that route.

rickmoynihan13:09:21

I personally avoid timbre, and the duct logger… and take the traditional approach of just using clojure.tools.logging with SLF4j redirecting everything (including ducts logger) over my backend. Whilst I’m sympathetic to duct’s purity ideals for logging, I want logs out of my dependencies too; and I’ve found it’s much less problematic to do things the java/logging way; and just use log4j2 to configure the logs and have the loggers initialised at startup outside of duct.

bocaj01:09:14

Yup, running into issues setting log level on apache/camel stuff from duct logger. I don’t have experience in java land handling log configuration, so 🤷

bocaj19:09:23

So, following up. I'm trying out threading a logger throughout code. I'm assuming it's a "code smell"

bocaj19:09:20

Here's a bit of config.edn

:watchdude.id-graph/init              {:db     #ig/ref :duct.database.sql/hikaricp
                                                               :logger #ig/ref :duct/logger}

                        [:duct/daemon :watchdude.routes/init] {:ctx       #ig/ref :watchdude.camel/ctx
                                                               :db        #ig/ref :duct.database.sql/hikaricp
                                                               :id-graph  #ig/ref :watchdude.id-graph/init
                                                               :watch-dir #wd/prop ["watchdude.watch.dir" Str :or "c:/tmp/watchdude-watch-dir"]
                                                               :repo-dir  #wd/prop ["watchdude.repo.dir" Str :or "c:/tmp/watchdude-repo-dir"]
                                                               :logger    #ig/ref :duct/logger}
Internal to routes/init, I pass the db to a model. That model calls a function from the id-graph component. So assuming I should model these call dependencies explicitly in the config.

rickmoynihan08:09:15

Sorry not sure what you’re asking.