How to debug the Convenient Service lib itself?

  • When something behaves unexpectedly and you suspect a bug in Convenient Service, enable debug mode by setting CONVENIENT_SERVICE_DEBUG=true before running your script.

    CONVENIENT_SERVICE_DEBUG=true ruby your_script.rb

    This automatically sets the Convenient Service internal logger level to Logger::DEBUG, producing verbose log output and full backtraces.

  • To check at runtime whether debug mode is active, call ConvenientService.debug?.

    ConvenientService.debug?
    # => false
    CONVENIENT_SERVICE_DEBUG=true ruby your_script.rb
    ConvenientService.debug?
    # => true
  • To enable verbose logging without the environment variable, set the logger level directly.

    ConvenientService.logger.level = Logger::DEBUG
  • To step through Convenient Service source code with a debugger, open the gem in your editor with bundle open.

    bundle open convenient_service

    Add binding.break at the suspect location, then trigger the code path via irb, Rails console, RSpec, or Rake. Remove the breakpoint after debugging.

    binding.break
  • binding.pry is a REPL, not a debugger - use binding.break, byebug, or extend pry with pry-byebug or similar when you need to step through code.

See also

Sources