Sha256: d555767f2a24f061316fda50d6e437876582f6e6c88b619ae55fda7cee96aaef

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 Bytes

Contents

module QPush
  module Server
    class << self
      STDOUT.sync = true

      def log
        @log ||= Log.new
      end
    end

    # The Log is a simple wrapper for the Logger. It outputs log info in a
    # defined manner to the console.
    #
    class Log
      def initialize
        @log = ::Logger.new(STDOUT)
        @log.formatter = proc do |_severity, _datetime, _progname, msg|
          "#{msg}\n"
        end
      end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qpush-0.1.10 lib/qpush/server/logger.rb