Class: CarrotRpc::TaggedLog

Inherits:
Object
  • Object
show all
Defined in:
lib/carrot_rpc/tagged_log.rb

Overview

Wrap the Logger object with convenience methods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger:, tags:) ⇒ TaggedLog

Returns a new instance of TaggedLog.



5
6
7
8
# File 'lib/carrot_rpc/tagged_log.rb', line 5

def initialize(logger:, tags:)
  @logger = logger
  @tags = *tags
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



3
4
5
# File 'lib/carrot_rpc/tagged_log.rb', line 3

def logger
  @logger
end

#tagsObject (readonly)

Returns the value of attribute tags.



3
4
5
# File 'lib/carrot_rpc/tagged_log.rb', line 3

def tags
  @tags
end

Instance Method Details

#levelObject



10
11
12
# File 'lib/carrot_rpc/tagged_log.rb', line 10

def level
  logger.level
end

#level=(level) ⇒ Object



14
15
16
# File 'lib/carrot_rpc/tagged_log.rb', line 14

def level=(level)
  logger.level = level
end

#with_correlation_id(correlation_id, &block) ⇒ Object



27
28
29
# File 'lib/carrot_rpc/tagged_log.rb', line 27

def with_correlation_id(correlation_id, &block)
  tagged("correlation_id=#{correlation_id}", &block)
end