Module: Wamp::Client::Logging

Defined in:
lib/wamp/client/logging.rb

Defined Under Namespace

Classes: Pretty, WithoutTimestamp

Constant Summary collapse

LOG_LEVEL_LOOKUP =
{
    error: Logger::ERROR,
    debug: Logger::DEBUG,
    info: Logger::INFO,
    warn: Logger::WARN,
}

Class Method Summary collapse

Class Method Details

.log_level=(log_level) ⇒ Object

Sets the log level

Parameters:

  • log_level (Symbol)
    • the desired log level



42
43
44
# File 'lib/wamp/client/logging.rb', line 42

def self.log_level=(log_level)
  self.logger.level = LOG_LEVEL_LOOKUP[log_level.to_sym] || :info
end

.loggerObject

Returns the logger object



29
30
31
32
33
34
35
36
37
# File 'lib/wamp/client/logging.rb', line 29

def self.logger
  unless defined?(@logger)
    $stdout.sync = true unless ENV['RAILS_ENV'] == "production"
    @logger = Logger.new $stdout
    @logger.level = Logger::INFO
    @logger.formatter = ENV['DYNO'] ? WithoutTimestamp.new : Pretty.new
  end
  @logger
end