Sha256: 9b8b69b9e6a76b0f833bab5771caea0be8ce3482b18f9d4c7951d1d6b3e25961
Contents?: true
Size: 1.1 KB
Versions: 35
Compression:
Stored size: 1.1 KB
Contents
require "singleton" require "colorize" module Bisu module Logger extend self def info(msg) log :info, msg end def warn(msg) log :warn, msg end def error(msg) log :error, msg end def clean_summary @levels.each { |k, _| @levels[k] = 0 } end def summary @levels end def print_summary if @levels[:warn] > 0 || @levels[:error] > 0 info "" info "Finished with:" info " #{@levels[:warn]} warnings" if @levels[:warn] > 0 info " #{@levels[:error]} errors" if @levels[:error] > 0 info "" end end def silent_mode=(value) @silent_mode = value end private @levels = { info: 0, warn: 0, error: 0 } @silent_mode = false def log(level, msg) unless @levels.keys.include?(level) return log(:error, "Unknown log level: #{level}") end @levels[level] += 1 msg = "[#{level.upcase}] #{msg}" msg = msg.yellow if level.eql?(:warn) msg = msg.red if level.eql?(:error) puts msg unless @silent_mode end end end
Version data entries
35 entries across 35 versions & 1 rubygems