Closed jcthalys closed 6 years ago
@jcthalys one way (and the one I thought about when I decided to use multimethods for each kind of message) is to provide a "silent" request-params
method for your printer, doing something like:
(defmethod messages/request-params :my-starting [_ _]
;; silent / do nothing
)
Now you might want to rename my-starting
to something else because it's not only about starting
anymore, but that's a separate discussion that I'll leave to you :)
Does that work for you?
@nberger I'm sorry, but a couldn't understand how to use two custom :printer
on this map that I'm passing to wrap-with-logger
if I alright using the starting
multimethod implementation?
How can I do to have the both implementations starting
and request-params
?
Thank you for the fast answer
@jcthalys you don't need to use two custom :printer
, just a single one. The value passed as :printer
in that map will be used to dispatch on the different multimethods defined in ring-logger.messages
.
Maybe it's confusing and we should have used a protocol to group the 6 different messages (starting
, request-details
, request-params
, sending-response
, finished
and exception
). Or use a totally different approach. #21 is somewhat related to this, I hope to put some thinking on it soon. But for now the easier thing is to define the methods for your printer using defmethod
and passing your printer dispatch value in the map.
Makes sense now?
perfectly clear now, so it worked, each one is a defmulti
implementation that just made dispatch for the same name
informed in :printer
.
(defmethod messages/starting :monitoring-logger
[{:keys [logger] :as options} req]
;; do samething
)
(defmethod messages/request-params :monitoring-logger [_ _]
;; silent / do nothing
)
;;;;;;
(wrap-with-logger {:printer :monitoring-logger})
Thank you
I'm implementing a custom printer multimethods to
starting
To avoid the others logs, I used only by the level of the log (
request-details, sending-response
), But therequest-params
it is alsoinfo
as thestarting
andfinished
. So, How can I stop log thisrequest-params
?