Module: Shoryuken::Logging

Defined in:
lib/shoryuken/logging.rb

Defined Under Namespace

Classes: Pretty

Class Method Summary collapse

Class Method Details

.initialize_logger(log_target = STDOUT) ⇒ Object


25
26
27
28
29
30
# File 'lib/shoryuken/logging.rb', line 25

def self.initialize_logger(log_target = STDOUT)
  @logger = Logger.new(log_target)
  @logger.level = Logger::INFO
  @logger.formatter = Pretty.new
  @logger
end

.loggerObject


32
33
34
# File 'lib/shoryuken/logging.rb', line 32

def self.logger
  @logger || initialize_logger
end

.logger=(log) ⇒ Object


36
37
38
# File 'lib/shoryuken/logging.rb', line 36

def self.logger=(log)
  @logger = (log ? log : Logger.new('/dev/null'))
end

.with_context(msg) ⇒ Object


18
19
20
21
22
23
# File 'lib/shoryuken/logging.rb', line 18

def self.with_context(msg)
  Thread.current[:shoryuken_context] = msg
  yield
ensure
  Thread.current[:shoryuken_context] = nil
end