Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2080,22 +2080,27 @@ def self.info msg
log :INFO, msg
end

def self.debug msg
log :DEBUG, msg
end

def self.log level, msg
@logfile = STDERR unless defined? @logfile

def self.check_loglevel level
lv = LOG_LEVELS[level]
config_lv = LOG_LEVELS[CONFIG[:log_level] || :WARN]
lv <= config_lv
end

if defined? SESSION
pi = SESSION.process_info
process_info = pi ? "[#{pi}]" : nil
def self.debug(&b)
if check_loglevel :DEBUG
log :DEBUG, b.call
end
end

def self.log level, msg
if check_loglevel level
@logfile = STDERR unless defined? @logfile

if defined? SESSION
pi = SESSION.process_info
process_info = pi ? "[#{pi}]" : nil
end

if lv <= config_lv
if level == :WARN
# :WARN on debugger is general information
@logfile.puts "DEBUGGER#{process_info}: #{msg}"
Expand Down
22 changes: 15 additions & 7 deletions lib/debug/thread_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1057,22 +1057,30 @@ def wait_next_action_
end

def debug_event(ev, args)
args = args.map { |arg| DEBUGGER__.safe_inspect(arg) }
DEBUGGER__.debug("#{inspect} sends Event { type: #{ev.inspect}, args: #{args} } to Session")
DEBUGGER__.debug{
args = args.map { |arg| DEBUGGER__.safe_inspect(arg) }
"#{inspect} sends Event { type: #{ev.inspect}, args: #{args} } to Session"
}
end

def debug_mode(old_mode, new_mode)
DEBUGGER__.debug("#{inspect} changes mode (#{old_mode} -> #{new_mode})")
DEBUGGER__.debug{
"#{inspect} changes mode (#{old_mode} -> #{new_mode})"
}
end

def debug_cmd(cmds)
cmd, *args = *cmds
args = args.map { |arg| DEBUGGER__.safe_inspect(arg) }
DEBUGGER__.debug("#{inspect} receives Cmd { type: #{cmd.inspect}, args: #{args} } from Session")
DEBUGGER__.debug{
cmd, *args = *cmds
args = args.map { |arg| DEBUGGER__.safe_inspect(arg) }
"#{inspect} receives Cmd { type: #{cmd.inspect}, args: #{args} } from Session"
}
end

def debug_suspend(event)
DEBUGGER__.debug("#{inspect} is suspended for #{event.inspect}")
DEBUGGER__.debug{
"#{inspect} is suspended for #{event.inspect}"
}
end

class Recorder
Expand Down