lib/trace-component.rb in canzea-0.1.1 vs lib/trace-component.rb in canzea-0.1.2

- old
+ new

@@ -1,13 +1,12 @@ require 'json' require 'open3' require 'stringio' require 'logger' +require 'audit' -# Optionally can specify the command to continue from -# Exit on first failure -# + def time_diff_milli(start, finish) (finish - start) * 1000.0 end def handleIO(stillOpen, ioArray, io, log) @@ -16,59 +15,9 @@ log.write(io.readpartial(4096)) rescue EOFError stillOpen.delete_if{|s| s == io} end end -end - - -class Audit - def start (id, cmd) - self.log( id, cmd, "start", "", 0, "") - end - - def complete (id, cmd, status, msecs, result) - self.log( id, cmd, "complete", status, msecs, result) - end - - def status (id, cmd, status, msecs, result) - data = { - "message" => { - "id" => id, - "cmd" => cmd, - "task" => "status", - "status" => status, - "elapsed" => msecs, - "result" => result - } - } - puts data.to_json - File.open(Canzea::config[:logging_root] + '/audit.log', 'a') { |file| file.puts(data.to_json) } - end - - def log (id, cmd, task, status, msecs, result) - data = { - "message" => { - "id" => id, - "cmd" => cmd, - "task" => task, - "status" => status, - "elapsed" => msecs, - "result" => result - } - } - summary = { - "message" => { - "id" => id, - "cmd" => cmd, - "task" => task, - "status" => status, - "elapsed" => msecs - } - } - puts summary.to_json - File.open(Canzea::config[:logging_root] + '/audit.log', 'a') { |file| file.puts(data.to_json) } - end end class ManagedError < StandardError end \ No newline at end of file