debug_logging

https://github.com/pboling/debug_logging

Ruby

Unobtrusive, configurable, drop-in debug logging useful when a call stack gets unruly

DebugLogging::Configuration#debug_enabled

LEVELS = { 0 => :debug, 1 => :info, 2 => :warn, 3 => :error, 4 => :fatal, 5 => :unknown }
alias the readers to the debug_* prefix so an instance of this class
  can have the same API granted by `extend DebugLogging`

    include DebugLogging::InstanceLogger.new(
      i_methods: [:drive, :stop],
      config: {
          logger: Logger.new(STDOUT) # probably want to override to be the Rails.logger
          log_level: :debug # at what level do the messages created by this gem sent at?
          last_hash_to_s_proc: nil # e.g. ->(hash) { "keys: #{hash.keys}" }
          last_hash_max_length: 1_000
          args_max_length: 1_000
          instance_benchmarks: false
          class_benchmarks: false
          add_invocation_id: true # invocation id allows you to identify a method call uniquely in a log
          ellipsis: " ✂️ …".freeze
      }
    )

Source | Google | Stack overflow

Edit

$ git clone [email protected]:pboling/debug_logging.git
$ cd debug_logging
$ open lib/debug_logging/configuration.rb

Contribute

# Make a new branch
$ git checkout -b -your-name--update-docs-DebugLogging--Configuration-debug_enabled-for-pr

# Commit to git
$ git add lib/debug_logging/configuration.rb
$ git commit -m "better docs for DebugLogging::Configuration#debug_enabled"

# Open pull request
$ gem install hub # on a mac you can `brew install hub`
$ hub fork
$ git push <your name> -your-name--update-docs-DebugLogging--Configuration-debug_enabled-for-pr
$ hub pull-request

# Celebrate!