Class: StructuredEventLogger
- Inherits:
-
Object
- Object
- StructuredEventLogger
- Defined in:
- lib/structured_event_logger.rb,
lib/structured_event_logger/version.rb
Constant Summary collapse
- CLEAR =
"\e[0m"- BOLD =
"\e[1m"- MAGENTA =
Colors
"\e[35m"- CYAN =
"\e[36m"- WHITE =
"\e[37m"- VERSION =
"0.0.3"
Instance Attribute Summary collapse
-
#colorize_logging ⇒ Object
readonly
Returns the value of attribute colorize_logging.
-
#default_context ⇒ Object
readonly
Returns the value of attribute default_context.
-
#json_io ⇒ Object
readonly
Returns the value of attribute json_io.
-
#unstructured_logger ⇒ Object
readonly
Returns the value of attribute unstructured_logger.
Instance Method Summary collapse
- #context ⇒ Object
- #event(scope, event, content = {}) ⇒ Object
-
#initialize(json_io, unstructured_logger = nil) ⇒ StructuredEventLogger
constructor
A new instance of StructuredEventLogger.
- #log(msg = nil) ⇒ Object
Constructor Details
#initialize(json_io, unstructured_logger = nil) ⇒ StructuredEventLogger
Returns a new instance of StructuredEventLogger.
16 17 18 19 20 21 |
# File 'lib/structured_event_logger.rb', line 16 def initialize(json_io, unstructured_logger = nil) @json_io, @unstructured_logger = json_io, unstructured_logger @thread_contexts = {} @default_context = {} @colorize_logging = ActiveSupport::LogSubscriber.colorize_logging end |
Instance Attribute Details
#colorize_logging ⇒ Object (readonly)
Returns the value of attribute colorize_logging.
14 15 16 |
# File 'lib/structured_event_logger.rb', line 14 def colorize_logging @colorize_logging end |
#default_context ⇒ Object (readonly)
Returns the value of attribute default_context.
14 15 16 |
# File 'lib/structured_event_logger.rb', line 14 def default_context @default_context end |
#json_io ⇒ Object (readonly)
Returns the value of attribute json_io.
14 15 16 |
# File 'lib/structured_event_logger.rb', line 14 def json_io @json_io end |
#unstructured_logger ⇒ Object (readonly)
Returns the value of attribute unstructured_logger.
14 15 16 |
# File 'lib/structured_event_logger.rb', line 14 def unstructured_logger @unstructured_logger end |
Instance Method Details
#context ⇒ Object
31 32 33 |
# File 'lib/structured_event_logger.rb', line 31 def context @thread_contexts[thread_key] ||= {} end |
#event(scope, event, content = {}) ⇒ Object
27 28 29 |
# File 'lib/structured_event_logger.rb', line 27 def event(scope, event, content = {}) log_event scope, event, flatten_hash(content) end |
#log(msg = nil) ⇒ Object
23 24 25 |
# File 'lib/structured_event_logger.rb', line 23 def log(msg = nil) unstructured_logger.add(nil, msg) end |