Git Product home page Git Product logo

dry-logger's Introduction

dry-logger Gem Version CI Status

Links

Supported Ruby versions

This library officially supports the following Ruby versions:

  • MRI >= 3.0
  • jruby >= 9.4 (not tested on CI)

License

See LICENSE file.

dry-logger's People

Contributors

davydovanton avatar dry-bot avatar flash-gordon avatar jodosha avatar komidore64 avatar olleolleolle avatar solnic avatar timriley avatar zsolt-rozsnyai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dry-logger's Issues

Using edge dry-logger fails to log SQL database lines.

I'm erring on the side of brevity here because it's dinner time and I really should step away from the keyboard, but also, because I know you're actively working on a new release and maybe this is something you want to investigate prior to that! ๐Ÿ˜…

I'm in the process of updating a sizeable app to Hanami 2.0.0.rc1, with all the corresponding dry-rb gem updates as well. Using dry-logger 1.0.0.rc2, ElasticSearch's logging fails, and I understand you've addressed that, so I've tried instead to run off the latest commits. When I do that locally, then I'm seeing a failure from within dry-logger, via dry-monitor's SQL logging. I'm using MRI 3.1.2 on macOS.

The full stack trace is below, but perhaps also of use: it's trying to format the following value and tokens:

value = "[%<progname>s] [%<severity>s] [%<time>s] %<verb>s %<status>s %<elapsed>s %<ip>s %<path>s %<length>s %<payload>s\n  %<params>s\n"
tokens = {:progname=>"readings", :severity=>"INFO", :time=>Time.parse("2022-11-15 20:16:07.513676 +1100"), :message=>"  Loaded :postgres in 1ms SELECT txid_snapshot_xmax(txid_current_snapshot()) AS txid", :payload=>""}

As per the error, the verb token is not present (along with other tokens as well). If other details are helpful, do let me know.

KeyError:
  key<verb> not found
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/formatters/template.rb:74:in `%'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/formatters/template.rb:74:in `%'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/formatters/string.rb:85:in `format'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/formatters/structured.rb:53:in `call'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/3.1.0/logger.rb:586:in `format_message'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/3.1.0/logger.rb:476:in `add'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/3.1.0/logger.rb:529:in `info'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/dispatcher.rb:173:in `block in log'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/dispatcher.rb:227:in `each'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/dispatcher.rb:227:in `block in each_backend'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/dispatcher.rb:226:in `synchronize'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/dispatcher.rb:226:in `each_backend'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/dispatcher.rb:172:in `log'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/dry-logger-19f74f6b49cc/lib/dry/logger/dispatcher.rb:106:in `info'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/dry-monitor-1.0.0/lib/dry/monitor/sql/logger.rb:56:in `log_query'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/dry-monitor-1.0.0/lib/dry/monitor/sql/logger.rb:52:in `block in subscribe'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/dry-monitor-1.0.0/lib/dry/monitor/notifications.rb:33:in `block in instrument'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/dry-events-1.0.0/lib/dry/events/bus.rb:38:in `block in process'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/dry-events-1.0.0/lib/dry/events/bus.rb:34:in `each'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/dry-events-1.0.0/lib/dry/events/bus.rb:34:in `process'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/dry-events-1.0.0/lib/dry/events/publisher.rb:269:in `process'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/dry-monitor-1.0.0/lib/dry/monitor/notifications.rb:31:in `instrument'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rom-sql-3.6.0/lib/rom/plugins/relation/sql/instrumentation.rb:72:in `block in define_log_connection_yield'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:171:in `execute_query'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:159:in `block in execute'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:136:in `check_disconnect_errors'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:159:in `execute'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:532:in `_execute'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:348:in `block (2 levels) in execute'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:555:in `check_database_errors'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:348:in `block in execute'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/connection_pool/threaded.rb:92:in `hold'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/database/connecting.rb:293:in `synchronize'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:348:in `execute'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/dataset/actions.rb:1162:in `execute'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/adapters/postgres.rb:651:in `fetch_rows'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/dataset/actions.rb:1003:in `with_sql_each'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/dataset/actions.rb:1011:in `with_sql_first'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/dataset/actions.rb:766:in `single_record!'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/dataset/actions.rb:754:in `single_record'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/sequel-5.62.0/lib/sequel/dataset/actions.rb:208:in `first'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/database_cleaner-sequel-2.0.2/lib/database_cleaner/sequel/truncation.rb:63:in `txid'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/database_cleaner-sequel-2.0.2/lib/database_cleaner/sequel/truncation.rb:57:in `dirty?'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/database_cleaner-sequel-2.0.2/lib/database_cleaner/sequel/truncation.rb:17:in `clean'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaner.rb:65:in `clean_with'
# ./spec/support/db/database_cleaner.rb:13:in `block (2 levels) in <top (required)>'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:365:in `run'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/configuration.rb:2155:in `block in run_suite_hooks'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/configuration.rb:2153:in `each'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/configuration.rb:2153:in `run_suite_hooks'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/configuration.rb:2067:in `with_suite_hooks'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:116:in `block in run_specs'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/reporter.rb:74:in `report'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:115:in `run_specs'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:89:in `run'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:71:in `run'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/exe/rspec:4:in `<top (required)>'
# /Users/pat/.asdf/installs/ruby/3.1.2/bin/rspec:25:in `load'
# /Users/pat/.asdf/installs/ruby/3.1.2/bin/rspec:25:in `<top (required)>'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `load'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:58:in `kernel_load'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/cli/exec.rb:23:in `run'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/cli.rb:479:in `exec'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/cli.rb:31:in `dispatch'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/cli.rb:25:in `start'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/exe/bundle:49:in `block in <top (required)>'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
# /Users/pat/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.2.33/exe/bundle:37:in `<top (required)>'
# /Users/pat/.asdf/installs/ruby/3.1.2/bin/bundle:25:in `load'
# /Users/pat/.asdf/installs/ruby/3.1.2/bin/bundle:25:in `<main>'

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.