Sha256: 096bb9752b0b0f08a7aa040368c3ac206114e7577ae286a46a1ded2bae3d851f
Contents?: true
Size: 631 Bytes
Versions: 5
Compression:
Stored size: 631 Bytes
Contents
module Loggerator alias_method :log_on, :log alias_method :log_error_on, :log_error def log_off(data, &block) block.call if block end def log_error_off(e, data={}, &block) block.call if block end class << self @@log_switch = true def turn_log(on_or_off) return unless %i[on off].include?(on_or_off.to_sym) alias_method :log, :"log_#{on_or_off}" alias_method :log_error, :"log_error_#{on_or_off}" @@log_switch = on_or_off.to_sym == :on end def log? @@log_switch end end end unless ENV.has_key?("TEST_LOGS") Loggerator.turn_log(:off) end
Version data entries
5 entries across 5 versions & 1 rubygems