Sha256: 0271b1abcc002ebcebde8ac9566b3d680ce5e1c27b9ba1d9dc018362dfc29325

Contents?: true

Size: 612 Bytes

Versions: 5

Compression:

Stored size: 612 Bytes

Contents

module RUPNP

  # Mixin to add log facility to others classes.
  # @author Sylvain Daubert
  module LogMixin


    # Log severity levels
    LOG_LEVEL = {
      :failure => 5,
      :error   => 4,
      :warn    => 3,
      :info    => 2,
      :debug   => 1
    }
    LOG_LEVEL.default = 0

    # log a message
    # @param [Symbol] level severity level.  May be +:debug+,
    #    +:info+, +warn+, or +:error+
    # @param [String] msg message to log
    def log(level, msg='')
      if LOG_LEVEL[level] >= LOG_LEVEL[RUPNP.log_level]
        RUPNP.logdev.puts "[#{level}] #{msg}"
      end
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rupnp-0.3.0 lib/rupnp/log_mixin.rb
rupnp-0.2.2 lib/rupnp/log_mixin.rb
rupnp-0.2.1 lib/rupnp/log_mixin.rb
rupnp-0.2.0 lib/rupnp/log_mixin.rb
rupnp-0.1.0 lib/rupnp/log_mixin.rb