Sha256: 9b8a4faa847c0b77fd08bebc67eb21b3af9e62f815a504d73248237dc1d81b82
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
require 'digest/xxhash' require 'semlogr/templates/parser' module Semlogr module Events class LogEvent attr_reader :severity attr_reader :template attr_reader :error attr_reader :properties attr_reader :timestamp def initialize(severity, template, error: nil, **properties) @timestamp = Time.now.utc @severity = severity @template = template @error = error @properties = properties end def self.create(severity, template, properties) template = Templates::Parser.parse(template) LogEvent.new(severity, template, properties) end def get_property(name) @properties[name] end def add_property(properties) @properties.merge!(properties) end def add_property_if_absent(properties) @properties.merge!(properties) { |_, old, _| old } end def render(output) @template.render(output, @properties) end def type @type ||= Digest::XXH32.hexdigest(@template.text) end def to_s output = '' render(output) output end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
semlogr-0.3.0 | lib/semlogr/events/log_event.rb |
semlogr-0.2.3 | lib/semlogr/events/log_event.rb |