Class: StructuredEventLogger
- Inherits:
-
Object
- Object
- StructuredEventLogger
- Defined in:
- lib/structured_event_logger.rb,
lib/structured_event_logger/version.rb
Defined Under Namespace
Classes: Error, EventHandlingException, HumanReadableLogger, JsonWriter, Syslogger
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Attribute Summary collapse
-
#default_context ⇒ Object
readonly
Returns the value of attribute default_context.
-
#endpoints ⇒ Object
readonly
Returns the value of attribute endpoints.
-
#error_handler ⇒ Object
Returns the value of attribute error_handler.
Instance Method Summary collapse
- #context ⇒ Object
- #event(scope, event, content = {}) ⇒ Object
-
#initialize(endpoints = {}) ⇒ StructuredEventLogger
constructor
A new instance of StructuredEventLogger.
Constructor Details
#initialize(endpoints = {}) ⇒ StructuredEventLogger
Returns a new instance of StructuredEventLogger.
18 19 20 21 22 23 24 |
# File 'lib/structured_event_logger.rb', line 18 def initialize(endpoints = {}) @endpoints = endpoints @thread_contexts = {} @default_context = {} @error_handler = lambda { |exception| raise(exception) } end |
Instance Attribute Details
#default_context ⇒ Object (readonly)
Returns the value of attribute default_context.
15 16 17 |
# File 'lib/structured_event_logger.rb', line 15 def default_context @default_context end |
#endpoints ⇒ Object (readonly)
Returns the value of attribute endpoints.
15 16 17 |
# File 'lib/structured_event_logger.rb', line 15 def endpoints @endpoints end |
#error_handler ⇒ Object
Returns the value of attribute error_handler.
16 17 18 |
# File 'lib/structured_event_logger.rb', line 16 def error_handler @error_handler end |
Instance Method Details
#context ⇒ Object
32 33 34 |
# File 'lib/structured_event_logger.rb', line 32 def context @thread_contexts[thread_key] ||= {} end |
#event(scope, event, content = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/structured_event_logger.rb', line 26 def event(scope, event, content = {}) log_event scope, event, flatten_hash(content) rescue EventHandlingException => e error_handler.call(e) end |