Sha256: 1ca11cd4d9f49d7f0ec48733612a7ac31312a541ca39727b656b296f7e4c9fc3
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
require 'json' require 'open3' require 'stringio' require 'logger' 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 } } context = { "step" => ENV['ES_STEP'], "ref" => ENV['ES_REF'], "role" => ENV['ES_ROLE'], "solution" => ENV['ES_SOLUTION'], "action" => ENV['ES_ACTION'] } summary['message'][:context] = context puts summary.to_json File.open(Canzea::config[:logging_root] + '/audit.log', 'a') { |file| file.puts(data.to_json) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
canzea-0.1.98 | lib/audit.rb |
canzea-0.1.97 | lib/audit.rb |