Class: SimpleStructuredLogger::Writer
- Inherits:
-
Object
- Object
- SimpleStructuredLogger::Writer
- Includes:
- Singleton
- Defined in:
- lib/simple_structured_logger.rb
Instance Attribute Summary collapse
-
#default_tags ⇒ Object
readonly
Returns the value of attribute default_tags.
Instance Method Summary collapse
- #debug(msg, opts = {}) ⇒ Object
- #error(msg, opts = {}) ⇒ Object
- #info(msg, opts = {}) ⇒ Object
-
#initialize ⇒ Writer
constructor
A new instance of Writer.
- #reset_context! ⇒ Object
- #set_context(context) ⇒ Object
- #warn(msg, opts = {}) ⇒ Object
Constructor Details
#initialize ⇒ Writer
Returns a new instance of Writer.
44 45 46 47 |
# File 'lib/simple_structured_logger.rb', line 44 def initialize @l = ::Logger.new(STDOUT) @default_tags = {} end |
Instance Attribute Details
#default_tags ⇒ Object (readonly)
Returns the value of attribute default_tags.
42 43 44 |
# File 'lib/simple_structured_logger.rb', line 42 def @default_tags end |
Instance Method Details
#debug(msg, opts = {}) ⇒ Object
67 68 69 |
# File 'lib/simple_structured_logger.rb', line 67 def debug(msg, opts={}) @l.debug("#{msg}: #{(opts)}") end |
#error(msg, opts = {}) ⇒ Object
59 60 61 |
# File 'lib/simple_structured_logger.rb', line 59 def error(msg, opts={}) @l.error("#{msg}: #{(opts)}") end |
#info(msg, opts = {}) ⇒ Object
63 64 65 |
# File 'lib/simple_structured_logger.rb', line 63 def info(msg, opts={}) @l.info("#{msg}: #{(opts)}") end |
#reset_context! ⇒ Object
49 50 51 |
# File 'lib/simple_structured_logger.rb', line 49 def reset_context! @default_tags = {} end |
#set_context(context) ⇒ Object
53 54 55 56 57 |
# File 'lib/simple_structured_logger.rb', line 53 def set_context(context) reset_context! @default_tags.merge!(context) end |
#warn(msg, opts = {}) ⇒ Object
71 72 73 |
# File 'lib/simple_structured_logger.rb', line 71 def warn(msg, opts={}) @l.warn("#{msg}: #{(opts)}") end |