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=truebefore running your script.CONVENIENT_SERVICE_DEBUG=true ruby your_script.rbThis 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? # => falseCONVENIENT_SERVICE_DEBUG=true ruby your_script.rbConvenientService.debug? # => trueTo enable verbose logging without the environment variable, set the logger level directly.
ConvenientService.logger.level = Logger::DEBUGTo step through Convenient Service source code with a debugger, open the gem in your editor with
bundle open.bundle open convenient_serviceAdd
binding.breakat the suspect location, then trigger the code path viairb, Rails console, RSpec, or Rake. Remove the breakpoint after debugging.binding.breakbinding.pryis a REPL, not a debugger - usebinding.break,byebug, or extend pry withpry-byebugor similar when you need to step through code.
See also
- What are Convenient Service dependencies?
- What is Convenient Service logger?
- How to configure Convenient Service logger?