Sha256: 83fc515d2b6a1c9023c2f0acc21339bd6b8e3e0e315d4c6372798557610994e4

Contents?: true

Size: 571 Bytes

Versions: 3

Compression:

Stored size: 571 Bytes

Contents

require 'logger'

class Radiodan
module Logging
  @@output = '/dev/null'
  
  def self.included(klass)
    klass.extend ClassMethods
  end
  
  def self.output=(output)
    @@output = output
  end
  
  def self.output
    @@output
  end

  def logger
    self.class.logger
  end

  module ClassMethods    
    @@logs = {}
    
    def logger
      unless @@logs.include? self.name
        new_log = Logger.new(Logging.output)
        new_log.progname = self.name
        
        @@logs[self.name] = new_log
      end
      
      @@logs[self.name]
    end
  end
end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radiodan-0.0.4 lib/radiodan/logging.rb
radiodan-0.0.3 lib/radiodan/logging.rb
radiodan-0.0.2 lib/radiodan/logging.rb