dry-logger
dry-logger copied to clipboard
Dry::Logger ignores log-payloads passed by block
I tried to plugin a Dry::Logger-instance at Faraday's logging middleware:
class MyRepo
include Deps["logger"]
def initialize(logger:)
@logger = logger
conn = Faraday.new(url: Ots::Slice[:settings].ots_endpoint) do |conn|
conn.response :logger, logger
end
end
end
The resulting logs are:
[services] [INFO] [2023-01-11 09:49:53 +0100] request
[services] [INFO] [2023-01-11 09:49:53 +0100] request
[services] [INFO] [2023-01-11 09:49:53 +0100] response
[services] [INFO] [2023-01-11 09:49:53 +0100] response
instead of
[services] [INFO] [2023-01-11 09:49:53 +0100] request: POST https://www.api.de
[services] [INFO] [2023-01-11 09:49:53 +0100] request: bla bla bla
[services] [INFO] [2023-01-11 09:49:53 +0100] response: Status 200
[services] [INFO] [2023-01-11 09:49:53 +0100] response: headers etc...
Faraday passes the log payload by block:
logger.info("request") { "hello" }
Is it expected that Dry::Logger differs from Ruby's Default Logger in this area?
https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html#method-i-info
thanks and best regards
This was an oversight. The intention is to have a compatible interface, so we gotta fix it.
I am running into this same situation while using HTTP.rb.
:bulb: You might want to check out Cogger for this due to having block support built in by default. Cogger is similar in spirit to this gem's Object API but with a lot more features, customization, etc.
@komidore64 Thanks for the nudge on this issue, I'll see if I can get a fix for you this week!
@timriley hey that's great news! I was planning to take a crack at it in the next couple days, but I imagine I'll be slower coming to a solution as I'll have to get used to the codebase first.
Thanks for the quick reply <3
@komidore64 ohh, in that case, please be my guest! 😍
And instead, I can promise you some very prompt PR reviews. I'm also happy to answer questions. You can jump into our forum (which now has chat!) to reach me 😄
ohh, in that case, please be my guest! 😍
Ok! I'll see what I can do.
And instead, I can promise you some very prompt PR reviews. I'm also happy to answer questions. You can jump into our forum (which now has chat!) to reach me 😄
Sounds great. Is your preference for me to reach out in the Hanami forum as opposed to dry-rb community forum? There is a (small, but) relevant thread in the dry-rb community space.
Regardless of communication location, I'm looking forward to working with you on this. Thanks a bunch!
Oh right, I had the wrong forum in mind when I linked that to you! If you have questions, happy for you to do so either here on this issue, or on the existing dry-rb forum thread. 😄
@timriley do we need to trigger a job somewhere to get new documentation to appear for dry-logger on dry-rb.org?