Module: Shoryuken::Logging

Defined in:
lib/shoryuken/logging.rb

Defined Under Namespace

Classes: Pretty

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initialize_logger(log_target = STDOUT) ⇒ Object


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

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

.loggerObject


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

def self.logger
  @logger || initialize_logger
end

.logger=(log) ⇒ Object


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

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

.with_context(msg) ⇒ Object


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

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

Instance Method Details

#loggerObject


41
42
43
# File 'lib/shoryuken/logging.rb', line 41

def logger
  shoryuken::Logging.logger
end