Class: StructuredEventLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/structured_event_logger.rb,
lib/structured_event_logger/version.rb

Defined Under Namespace

Classes: HumanReadableLogger, JsonWriter

Constant Summary collapse

VERSION =
"0.0.6"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoints = {}) ⇒ StructuredEventLogger

Returns a new instance of StructuredEventLogger.



6
7
8
9
10
11
# File 'lib/structured_event_logger.rb', line 6

def initialize(endpoints = {})
  @endpoints = endpoints

  @thread_contexts = {}
  @default_context = {}
end

Instance Attribute Details

#default_contextObject (readonly)

Returns the value of attribute default_context.



4
5
6
# File 'lib/structured_event_logger.rb', line 4

def default_context
  @default_context
end

#endpointsObject (readonly)

Returns the value of attribute endpoints.



4
5
6
# File 'lib/structured_event_logger.rb', line 4

def endpoints
  @endpoints
end

Instance Method Details

#contextObject



17
18
19
# File 'lib/structured_event_logger.rb', line 17

def context
  @thread_contexts[thread_key] ||= {}
end

#event(scope, event, content = {}) ⇒ Object



13
14
15
# File 'lib/structured_event_logger.rb', line 13

def event(scope, event, content = {})
  log_event scope, event, flatten_hash(content)
end