Sha256: 1cd1bbd4fc09b7ce2430694a90aee193497ef274e8620087f4ac286e3ab77915

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

module Log

  DEBUG  = 0
  LOW    = 1
  MEDIUM = 2
  HIGH   = 3

  def self.severity=(severity)
    @@severity = severity
  end

  def self.severity
    @@severity
  end

  def self.log(message, severity = MEDIUM)
    STDERR.puts "#{Time.now}[#{severity.to_s}]: " +  message if severity >= @@severity
  end

  def self.debug(message)
    log(message, DEBUG)
  end

  def self.low(message)
    log(message, LOW)
  end

  def self.medium(message)
    log(message, MEDIUM)
  end

  def self.high(message)
    log(message, HIGH)
  end

  case ENV['RBBT_LOG']
  when 'DEBUG' 
    @@severity = DEBUG
  when 'LOW' 
    @@severity = LOW
  when 'MEDIUM' 
    @@severity = MEDIUM
  when 'HIGH' 
    @@severity = HIGH
  when nil
    @@severity = HIGH
  else
    @@severity = ENV['RBBT_LOG'].to_i
  end
end

def ddd(message, file = $stdout)
  Log.debug "DEVEL => " << caller.first
  Log.debug "DEVEL: " << message.inspect
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbbt-util-1.2.1 lib/rbbt/util/log.rb