Class: Raykit::LogEvent

Inherits:
Hash
  • Object
show all
Defined in:
lib/raykit/logevent.rb

Overview

:verbose, :debug, :information, :error, :fatal

Instance Method Summary collapse

Constructor Details

#initialize(level, messageTemplate, properties) ⇒ LogEvent

Returns a new instance of LogEvent.



8
9
10
11
12
13
14
15
16
17
# File 'lib/raykit/logevent.rb', line 8

def initialize(level, messageTemplate, properties)
  self["Timestamp"] = DateTime.now.iso8601
  self["Level"] = level
  self["Message"] = messageTemplate
  self["MessageTemplate"] = messageTemplate
  properties["MachineName"] = Raykit::Environment.machine unless properties.key?("MachineName")
  properties["UserName"] = Raykit::Environment.user unless properties.key?("UserName")
  properties["RakeDirectory"] = ::Rake.application.original_dir
  self["Properties"] = properties
end

Instance Method Details

#to_seqObject



19
20
21
22
23
24
25
26
27
# File 'lib/raykit/logevent.rb', line 19

def to_seq
  unless ENV["SEQ_SERVER"].nil?
    cmd_str = "seqcli log -m \"#{self["Message"].gsub('"', "")}\" -l #{self["Level"]} -s #{ENV["SEQ_SERVER"]}"
    self["Properties"].each do |k, v|
      cmd_str += " -p \"#{k}=#{v}\""
    end
    puts `#{cmd_str}`
  end
end