Sha256: 7c71e85404f10c76e662a488161468e3ff1561c73310deb7d3d9f44ea6b8518e

Contents?: true

Size: 1.1 KB

Versions: 432

Compression:

Stored size: 1.1 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 %Q{
            def #{name}(message)
              #{options.fetch(:to, :log)}(#{name.inspect}, message)
            end
          }
        end
      end
      
    end
  end
end

Version data entries

432 entries across 151 versions & 7 rubygems

Version Path
sass-3.2.0.alpha.70 lib/sass/logger/log_level.rb
sass-3.1.14 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.64 lib/sass/logger/log_level.rb
sass-3.1.13 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.61 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.59 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.63 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.62 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.60 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.57 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.56 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.55 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.54 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.53 lib/sass/logger/log_level.rb
haml-3.2.0.alpha.10 vendor/sass/lib/sass/logger/log_level.rb
sass-3.2.0.alpha.49 lib/sass/logger/log_level.rb
sass-3.1.12 lib/sass/logger/log_level.rb
haml-3.1.4 vendor/sass/lib/sass/logger/log_level.rb
sass-3.1.11 lib/sass/logger/log_level.rb
sass-3.2.0.alpha.35 lib/sass/logger/log_level.rb