class ItamaeMitsurin::Handler::Json

Public Class Methods

new(*) click to toggle source
Calls superclass method ItamaeMitsurin::Handler::Base::new
# File lib/itamae-mitsurin/handler/json.rb, line 4
def initialize(*)
  super
  require 'time'
  open_file
end

Public Instance Methods

event(type, payload = {}) click to toggle source
Calls superclass method ItamaeMitsurin::Handler::Base#event
# File lib/itamae-mitsurin/handler/json.rb, line 10
def event(type, payload = {})
  super
  @f.puts({'time' => Time.now.iso8601, 'event' => type, 'payload' => payload}.to_s.encode.to_json)
end

Private Instance Methods

open_file() click to toggle source
# File lib/itamae-mitsurin/handler/json.rb, line 17
def open_file
  logs_path = @options.values.join
  @options={"path" => "#{logs_path + '.' + Time.now.strftime("%Y%m%d")}"}
  @f = open(@options.fetch('path'), 'a')
end