Skip to content

Commit e1118c8

Browse files
committed
Adjust format
1 parent 8ffbaf2 commit e1118c8

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

lib/debug/session.rb

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ def session_server_main
203203
def process_event evt
204204
# variable `@internal_info` is only used for test
205205
tc, output, ev, @internal_info, *ev_args = evt
206-
debug_event(tc, ev, ev_args)
207206
output.each{|str| @ui.puts str} if ev != :suspend
208207

209208
case ev
@@ -1717,10 +1716,6 @@ def before_fork need_lock = true
17171716
def after_fork_parent
17181717
@ui.after_fork_parent
17191718
end
1720-
1721-
def debug_event(*args)
1722-
DEBUGGER__.debug_event(*args, direction: ">")
1723-
end
17241719
end
17251720

17261721
class ProcessGroup
@@ -2039,27 +2034,23 @@ def self.debug msg
20392034
log :DEBUG, msg
20402035
end
20412036

2042-
# to avoid computing the large number of debug strings unnecessarily
2043-
DEBUG_MODE = CONFIG[:log_level] == :DEBUG
2044-
2045-
def self.debug_event(tc, ev, ev_args, direction:)
2046-
return unless DEBUG_MODE
2047-
DEBUGGER__.debug("#{direction} Event (#{ev}): #{ev_args} | #{tc} ")
2037+
def self.debug_event(tc, ev, args)
2038+
args = args.map { |arg| safe_inspect(arg) }
2039+
debug("#{tc.inspect} sent Event { type: #{ev.inspect}, args: #{args} } to Session")
20482040
end
20492041

20502042
def self.debug_mode(tc, old_mode, new_mode)
2051-
return unless DEBUG_MODE
2052-
DEBUGGER__.debug("Mode: #{old_mode} -> #{new_mode} | #{tc}")
2043+
debug("#{tc.inspect} changed mode (#{old_mode} -> #{new_mode})")
20532044
end
20542045

2055-
def self.debug_cmd(tc, cmd, direction:)
2056-
return unless DEBUG_MODE
2057-
DEBUGGER__.debug("#{direction} Cmd #{cmd} | #{tc}")
2046+
def self.debug_cmd(tc, cmds)
2047+
cmd, *args = *cmds
2048+
args = args.map { |arg| safe_inspect(arg) }
2049+
debug("#{tc.inspect} received Cmd { type: #{cmd.inspect}, args: #{args} } from Session")
20582050
end
20592051

20602052
def self.debug_suspend(tc, event)
2061-
return unless DEBUG_MODE
2062-
DEBUGGER__.debug("Suspend #{event} | #{tc}")
2053+
debug("#{tc.inspect} was suspended for #{event.inspect}")
20632054
end
20642055

20652056
def self.log level, msg

lib/debug/thread_client.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def puts str = ''
181181
end
182182

183183
def << req
184-
DEBUGGER__.debug_cmd(self, req, direction: ">>")
184+
DEBUGGER__.debug_cmd(self, req)
185185
@q_cmd << req
186186
end
187187

@@ -191,12 +191,8 @@ def generate_info
191191
{ location: current_frame.location_str, line: current_frame.location.lineno }
192192
end
193193

194-
def debug_event(*args)
195-
DEBUGGER__.debug_event(self, *args, direction: "<")
196-
end
197-
198194
def event! ev, *args
199-
debug_event(ev, args)
195+
DEBUGGER__.debug_event(self, ev, args)
200196
@q_evt << [self, @output, ev, generate_info, *args]
201197
@output = []
202198
end
@@ -704,8 +700,6 @@ def wait_next_action_
704700
begin
705701
set_mode :waiting if !waiting?
706702
cmds = @q_cmd.pop
707-
708-
DEBUGGER__.debug_cmd(self, cmds, direction: "<<")
709703
# pp [self, cmds: cmds]
710704
break unless cmds
711705
ensure

0 commit comments

Comments
 (0)