Class: Contr::Logger::Default
Constant Summary collapse
- DEFAULT_STREAM =
$stdout
- DEFAULT_LOG_LEVEL =
:debug
- DEFAULT_TAG =
"contract-failed"
Instance Attribute Summary collapse
-
#log_level ⇒ Object
readonly
Returns the value of attribute log_level.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
-
#stream_logger ⇒ Object
readonly
Returns the value of attribute stream_logger.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
-
#initialize(stream: DEFAULT_STREAM, log_level: DEFAULT_LOG_LEVEL, tag: DEFAULT_TAG) ⇒ Default
constructor
A new instance of Default.
- #log(state) ⇒ Object
Constructor Details
#initialize(stream: DEFAULT_STREAM, log_level: DEFAULT_LOG_LEVEL, tag: DEFAULT_TAG) ⇒ Default
Returns a new instance of Default.
15 16 17 18 19 20 |
# File 'lib/contr/logger/default.rb', line 15 def initialize(stream: DEFAULT_STREAM, log_level: DEFAULT_LOG_LEVEL, tag: DEFAULT_TAG) @stream = stream @stream_logger = ::Logger.new(stream) @log_level = log_level @tag = tag end |
Instance Attribute Details
#log_level ⇒ Object (readonly)
Returns the value of attribute log_level.
13 14 15 |
# File 'lib/contr/logger/default.rb', line 13 def log_level @log_level end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
13 14 15 |
# File 'lib/contr/logger/default.rb', line 13 def stream @stream end |
#stream_logger ⇒ Object (readonly)
Returns the value of attribute stream_logger.
13 14 15 |
# File 'lib/contr/logger/default.rb', line 13 def stream_logger @stream_logger end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
13 14 15 |
# File 'lib/contr/logger/default.rb', line 13 def tag @tag end |
Instance Method Details
#log(state) ⇒ Object
22 23 24 25 26 |
# File 'lib/contr/logger/default.rb', line 22 def log(state) = state.merge(tag: tag).to_json stream_logger.send(log_level, ) end |