Module: AIPP::Debugger
- Included in:
- Downloader, Executable, Parser, Runner
- Defined in:
- lib/aipp/debugger.rb
Instance Method Summary collapse
-
#info(message, color: nil) ⇒ Object
Issue an informational message.
- #original_warn ⇒ Object
-
#verbose_info(message, color: :blue) ⇒ Object
Issue a verbose informational message.
-
#warn(message, severe: true) ⇒ Object
Issue a warning and maybe open a debug session.
-
#with_debugger(debug_on_warning: , debug_on_error: , verbose: ) { ... } ⇒ Object
Start a debugger session and watch for warnings etc.
Instance Method Details
#info(message, color: nil) ⇒ Object
Issue an informational message.
60 61 62 63 64 |
# File 'lib/aipp/debugger.rb', line 60 def info(, color: nil) unless AIPP..quiet puts color ? .upcase_first.send(color) : .upcase_first end end |
#original_warn ⇒ Object
42 |
# File 'lib/aipp/debugger.rb', line 42 alias_method :original_warn, :warn |
#verbose_info(message, color: :blue) ⇒ Object
Issue a verbose informational message.
70 71 72 |
# File 'lib/aipp/debugger.rb', line 70 def verbose_info(, color: :blue) info(, color: color) if AIPP..verbose end |
#warn(message, severe: true) ⇒ Object
Issue a warning and maybe open a debug session.
48 49 50 51 52 53 54 |
# File 'lib/aipp/debugger.rb', line 48 def warn(, severe: true) if severe || AIPP..verbose AIPP.cache.debug_counter += 1 original_warn "WARNING #{AIPP.cache.debug_counter}: #{.upcase_first} #{'(unsevere)' unless severe}".red debugger if AIPP..debug_on_warning == true || AIPP..debug_on_warning == AIPP.cache.debug_counter end end |
#with_debugger(debug_on_warning: , debug_on_error: , verbose: ) { ... } ⇒ Object
Note:
The debugger session persists beyond the scope of the given block because there’s no DEBUGGER__.stop
as of now.
Start a debugger session and watch for warnings etc
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/aipp/debugger.rb', line 25 def with_debugger(&) AIPP.cache.debug_counter = 0 case when id = AIPP..debug_on_warning puts instructions_for(@id == true ? 'warning' : "warning #{id}") DEBUGGER__::start(no_sigint_hook: true, nonstop: true) call_with_rescue(&) when AIPP..debug_on_error puts instructions_for('error') DEBUGGER__::start(no_sigint_hook: true, nonstop: true, postmortem: true) call_without_rescue(&) else DEBUGGER__::start(no_sigint_hook: true, nonstop: true) call_with_rescue(&) end end |