Skip to content

Commit e188009

Browse files
committed
Improve debug log's format
1 parent 0c97b87 commit e188009

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

lib/debug/session.rb

Lines changed: 9 additions & 12 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
@@ -2044,21 +2039,23 @@ def self.debug
20442039
end
20452040
end
20462041

2047-
def self.debug_event(tc, ev, ev_args, direction:)
2048-
debug { "#{direction} Event (#{ev}): #{ev_args} | #{tc} " }
2042+
def self.debug_event(tc, ev, ev_args)
2043+
debug { "#{tc} sent Event { type: #{ev.inspect}, args: #{ev_args} } to Session" }
20492044
end
20502045

20512046
def self.debug_mode(tc, old_mode, new_mode)
2052-
debug { "!! Mode: #{old_mode} -> #{new_mode} | #{tc}" }
2047+
debug { "#{tc} changed mode (#{old_mode} -> #{new_mode})" }
20532048
end
20542049

2055-
def self.debug_cmd(tc, cmds, direction:)
2056-
cmd, *args = *cmds
2057-
debug { "#{direction} Cmd (#{cmd}): #{args} | #{tc}" }
2050+
def self.debug_cmd(tc, cmds)
2051+
debug do
2052+
cmd, *args = *cmds
2053+
"#{tc} received Cmd { type: #{cmd.inspect}, args: #{args} } from Session"
2054+
end
20582055
end
20592056

20602057
def self.debug_suspend(tc, event)
2061-
debug { "!! Suspend: #{event} | #{tc}" }
2058+
debug { "#{tc} was suspended for #{event.inspect}" }
20622059
end
20632060

20642061
def self.log level, msg

lib/debug/thread_client.rb

Lines changed: 2 additions & 7 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
@@ -710,7 +706,6 @@ def wait_next_action_
710706
set_mode :running
711707
end
712708

713-
DEBUGGER__.debug_cmd(self, cmds, direction: "<<")
714709
cmd, *args = *cmds
715710

716711
case cmd

0 commit comments

Comments
 (0)