Hi guys, new user of Duct here, I am going over the example app on duct github wiki page. Now if I want to disable default logger and use timbre. I can just put this under :duct.profile/base key:
IIRC the default logger is timbre https://github.com/duct-framework/module.logging/blob/master/src/duct/module/logging.clj
Ah I see. But I am still having trouble getting the logger reference from integrant.
(defmethod ig/init-key ::create [_ {:keys [db logger]}]
(fn [{[_ email password] :ataraxy/result}]
(let [id (create-user db email password)]
(println logger)
(log logger :info ::create {:email email})
[::response/created (str "/users/" id)])))logger has this value: {:enabled? true, :fn #function[taoensso.timbre.appenders.core/spit-appender/self--15048]}I was passing the wrong key, :duct.logger/timbre is the correct one
You can reference it by :duct/logger.
https://github.com/duct-framework/logger.timbre/blob/master/src/duct_hierarchy.edn
:duct.logger/timbre implements the :duct/logger interface.
👍 clear and thanks.
:duct.logger/timbre
{:level :info
:appenders {:spit #ig/ref :duct.logger.timbre/spit}}
:duct.logger.timbre/spit {:fname "logs/server.log"}And then in the create user handler key i need to reference :duct.logger/timbre
:todo.handler.users/create
{:db #ig/ref :duct.database/sql
:logger #ig/ref :duct.logger/timbre}And then in the init-key multimethod for my todo.handlers.users/create i can just reference the passed logger like this
(defmethod ig/init-key ::create [_ {:keys [db logger]}]
(fn [{[_ email password] :ataraxy/result}]
(let [id (create-user db email password)]
(log logger :info ::create {:email email})
[::response/created (str "/users/" id)])))Then I can just remove the :duct.module/logging key from the config. Am I doing this right? It does work.