Sha256: d51f6041bc6f433b7b4ecdb49ee2631ed0dc98f58efd9d15ecd61f00b15e2248

Contents?: true

Size: 1.13 KB

Versions: 119

Compression:

Stored size: 1.13 KB

Contents

module Sass
  module Logger
    module LogLevel

      def self.included(base)
        base.extend(ClassMethods)
      end
      
      module ClassMethods
        def inherited(subclass)
          subclass.log_levels = subclass.superclass.log_levels.dup
        end

        def log_levels
          @log_levels ||= {}
        end

        def log_levels=(levels)
          @log_levels = levels
        end

        def log_level?(level, min_level)
          log_levels[level] >= log_levels[min_level]
        end

        def log_level(name, options = {})
          if options[:prepend]
            level = log_levels.values.min
            level = level.nil? ? 0 : level - 1
          else
            level = log_levels.values.max
            level = level.nil? ? 0 : level + 1
          end
          log_levels.update(name => level)
          define_logger(name)
        end

        def define_logger(name, options = {})
          class_eval <<-RUBY, __FILE__, __LINE__ + 1
            def #{name}(message)
              #{options.fetch(:to, :log)}(#{name.inspect}, message)
            end
          RUBY
        end
      end
      
    end
  end
end

Version data entries

119 entries across 114 versions & 11 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/sass-3.2.19/lib/sass/logger/log_level.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/sass-3.2.19/lib/sass/logger/log_level.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/sass-3.2.5/lib/sass/logger/log_level.rb
xass-0.1.0 lib/sass/logger/log_level.rb
oreorenasass-3.4.14 lib/sass/logger/log_level.rb
oreorenasass-3.4.13 lib/sass/logger/log_level.rb
oreorenasass-3.4.12 lib/sass/logger/log_level.rb
oreorenasass-3.4.11 lib/sass/logger/log_level.rb
oreorenasass-3.4.9 lib/sass/logger/log_level.rb
oreorenasass-3.4.7 lib/sass/logger/log_level.rb
oreorenasass-3.4.5 lib/sass/logger/log_level.rb
sadui-0.0.4 vendor/bundle/ruby/2.0.0/gems/sass-3.2.14/lib/sass/logger/log_level.rb
sadui-0.0.4 vendor/bundle/ruby/2.1.0/gems/sass-3.2.14/lib/sass/logger/log_level.rb
sass-3.2.19 lib/sass/logger/log_level.rb
sass-3.2.18 lib/sass/logger/log_level.rb
sass-3.2.17 lib/sass/logger/log_level.rb
sass-3.2.16 lib/sass/logger/log_level.rb
sass-3.2.15 lib/sass/logger/log_level.rb
sass-3.2.14 lib/sass/logger/log_level.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/sass-3.2.13/lib/sass/logger/log_level.rb