Sha256: e09e247c50bc58c4932ee449b07b8eca959a25f12a567c0203a3869d66ac88dc

Contents?: true

Size: 514 Bytes

Versions: 1

Compression:

Stored size: 514 Bytes

Contents

require 'logger'

module ActiveHook
  class << self
    STDOUT.sync = true

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activehook-0.1.0 lib/activehook/log.rb