Class: QPush::Server::Log
- Inherits:
-
Object
- Object
- QPush::Server::Log
- 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
-
#err(msg, action: :no_exit) ⇒ Object
Creates a new error log message.
-
#info(msg) ⇒ Object
Creates a new info log message.
-
#initialize ⇒ Log
constructor
A new instance of Log.
Constructor Details
#initialize ⇒ Log
15 16 17 18 19 20 |
# File 'lib/qpush/server/logger.rb', line 15 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.
30 31 32 33 |
# File 'lib/qpush/server/logger.rb', line 30 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.
24 25 26 |
# File 'lib/qpush/server/logger.rb', line 24 def info(msg) @log.info("[ \e[32mOK\e[0m ] #{msg}") end |