Class: Tracemake::MakeTraceWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/tracemake.rb

Overview

Writer for MakeTrace format

Instance Method Summary collapse

Constructor Details

#initialize(trace_file) ⇒ MakeTraceWriter

Returns a new instance of MakeTraceWriter.



81
82
83
84
# File 'lib/tracemake.rb', line 81

def initialize(trace_file)
  @trace_file = trace_file
  FileUtils.mkdir_p(File.dirname(@trace_file))
end

Instance Method Details

#write_begin_event(pid, time, args) ⇒ Object



86
87
88
89
90
91
92
93
# File 'lib/tracemake.rb', line 86

def write_begin_event(pid, time, args)
  write_event({
    "pid" => pid,
    "type" => "B",
    "time" => time,
    "args" => args
  })
end

#write_end_event(pid, time, exit_status = nil) ⇒ Object



95
96
97
98
99
100
101
102
103
# File 'lib/tracemake.rb', line 95

def write_end_event(pid, time, exit_status = nil)
  event = {
    "pid" => pid,
    "type" => "E",
    "time" => time
  }
  event["exit_status"] = exit_status if exit_status
  write_event(event)
end