Class: Enceladus::Logger

Inherits:
Logger
  • Object
show all
Includes:
Singleton
Defined in:
lib/enceladus/logger.rb

Overview

Logger is a class implemented by using the singleton pattern mainly responsible for loggin requests, responses and exceptions. Examples:

Enceladus::Logger.log.error { "Woops! Something when wrong..." }
Enceladus::Logger.log.info { "Yay! That works like a charm!" }
Enceladus::Logger.log.warn { "Hummm... code smells here..." }
Enceladus::Logger.log.fatal { "Game over..." }

Constant Summary collapse

@@logger_output =

By default Enceladus::Logger logs messages to STDOUT and the default log level is Logger::ERROR (check out www.ruby-doc.org/stdlib-2.0.0/libdoc/logger/rdoc/Logger.html#class-Logger-label-Description for more information).

STDOUT

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.logger_outputObject

Returns the current logger output. Example:

Enceladus::Logger.logger_output
=> "/Users/john/super_project/log/enceladus.log"


39
40
41
# File 'lib/enceladus/logger.rb', line 39

def logger_output
  @@logger_output
end

.logger_output=(output) ⇒ Object

Defines where to log messages. Example:

Enceladus::Logger.logger_output = Rails.root.join("log", "enceladus.log")


30
31
32
# File 'lib/enceladus/logger.rb', line 30

def logger_output=(output)
  @@logger_output = output
end

.newObject



18
19
20
21
22
# File 'lib/enceladus/logger.rb', line 18

def new
  super(logger_output).tap do |logger|
    logger.disable_debug_mode!
  end
end

Instance Method Details

#disable_debug_mode!Object

Disables the debug mode by changing the log level to ERROR. Example:

Enceladus::Logger.instance.disable_debug_mode!


54
55
56
# File 'lib/enceladus/logger.rb', line 54

def disable_debug_mode!
  self.level = Enceladus::Logger::ERROR
end

#enable_debug_mode!Object

Changes the log level to DEBUG. Example:

Enceladus::Logger.instance.enable_debug_mode!


47
48
49
# File 'lib/enceladus/logger.rb', line 47

def enable_debug_mode!
  self.level = Enceladus::Logger::DEBUG
end