Module: Creeper::Logging

Defined in:
lib/creeper/logging.rb

Defined Under Namespace

Classes: Pretty

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loggerObject



28
29
30
31
32
33
34
35
# File 'lib/creeper/logging.rb', line 28

def self.logger
  @logger ||= begin
    log = Logger.new(STDOUT)
    log.level = Logger::INFO
    log.formatter = Pretty.new
    log
  end
end

.logger=(log) ⇒ Object



37
38
39
# File 'lib/creeper/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
25
26
# File 'lib/creeper/logging.rb', line 19

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

Instance Method Details

#loggerObject



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

def logger
  Creeper::Logging.logger
end