Class: Semlogr::Events::LogEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/semlogr/events/log_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(severity, template, error, properties) ⇒ LogEvent

Returns a new instance of LogEvent.



10
11
12
13
14
15
16
# File 'lib/semlogr/events/log_event.rb', line 10

def initialize(severity, template, error, properties)
  @timestamp = Time.now.utc
  @severity = severity
  @template = template
  @error = error
  @properties = properties
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



6
7
8
# File 'lib/semlogr/events/log_event.rb', line 6

def error
  @error
end

#propertiesObject (readonly)

Returns the value of attribute properties.



7
8
9
# File 'lib/semlogr/events/log_event.rb', line 7

def properties
  @properties
end

#severityObject (readonly)

Returns the value of attribute severity.



4
5
6
# File 'lib/semlogr/events/log_event.rb', line 4

def severity
  @severity
end

#templateObject (readonly)

Returns the value of attribute template.



5
6
7
# File 'lib/semlogr/events/log_event.rb', line 5

def template
  @template
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



8
9
10
# File 'lib/semlogr/events/log_event.rb', line 8

def timestamp
  @timestamp
end

Instance Method Details

#add_property(properties) ⇒ Object



22
23
24
# File 'lib/semlogr/events/log_event.rb', line 22

def add_property(properties)
  @properties.merge!(properties)
end

#get_property(name) ⇒ Object



18
19
20
# File 'lib/semlogr/events/log_event.rb', line 18

def get_property(name)
  @properties[name]
end

#render(output) ⇒ Object



26
27
28
# File 'lib/semlogr/events/log_event.rb', line 26

def render(output)
  @template.render(output, @properties)
end

#to_sObject



30
31
32
33
34
35
36
# File 'lib/semlogr/events/log_event.rb', line 30

def to_s
  output = ''

  render(output)

  output
end