Class: QPush::Server::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/qpush/server/logger.rb

Overview

The Log is a simple wrapper for the Logger. It outputs log info in a defined manner to the console.

Instance Method Summary collapse

Constructor Details

#initializeLog

Returns a new instance of Log.



17
18
19
20
21
22
# File 'lib/qpush/server/logger.rb', line 17

def initialize
  @log = ::Logger.new(STDOUT)
  @log.formatter = proc do |_severity, _datetime, _progname, msg|
    "#{msg}\n"
  end
end

Instance Method Details

#err(msg, action: :no_exit) ⇒ Object

Creates a new error log message.



32
33
34
35
# File 'lib/qpush/server/logger.rb', line 32

def err(msg, action: :no_exit)
  @log.info("[ \e[31mER\e[0m ] #{msg}")
  exit 1 if action == :exit
end

#info(msg) ⇒ Object

Creates a new info log message.



26
27
28
# File 'lib/qpush/server/logger.rb', line 26

def info(msg)
  @log.info("[ \e[32mOK\e[0m ] #{msg}")
end