Module: Sass::Logger::LogLevel::ClassMethods

Defined in:
lib/sass/logger/log_level.rb

Instance Method Summary collapse

Instance Method Details

#define_logger(name, options = {})



38
39
40
41
42
43
44
# File 'lib/sass/logger/log_level.rb', line 38

def define_logger(name, options = {})
  class_eval %Q{
    def #{name}(message)
      #{options.fetch(:to, :log)}(#{name.inspect}, message)
    end
  }
end

#inherited(subclass)



10
11
12
# File 'lib/sass/logger/log_level.rb', line 10

def inherited(subclass)
  subclass.log_levels = subclass.superclass.log_levels.dup
end

#log_level(name, options = {})



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sass/logger/log_level.rb', line 26

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

#log_level?(level, min_level) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/sass/logger/log_level.rb', line 22

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

#log_levels



14
15
16
# File 'lib/sass/logger/log_level.rb', line 14

def log_levels
  @log_levels ||= {}
end

#log_levels=(levels)



18
19
20
# File 'lib/sass/logger/log_level.rb', line 18

def log_levels=(levels)
  @log_levels = levels
end