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

Defined in:
/home/nweiz/code/sass-site/.sass/lib/sass/logger/log_level.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- log_levels



15
16
17
# File '/home/nweiz/code/sass-site/.sass/lib/sass/logger/log_level.rb', line 15

def log_levels
  @log_levels ||= {}
end

Instance Method Details

- define_logger(name, options = {})



35
36
37
38
39
40
41
# File '/home/nweiz/code/sass-site/.sass/lib/sass/logger/log_level.rb', line 35

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

- inherited(subclass)



9
10
11
# File '/home/nweiz/code/sass-site/.sass/lib/sass/logger/log_level.rb', line 9

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

- log_level(name, options = {})



23
24
25
26
27
28
29
30
31
32
33
# File '/home/nweiz/code/sass-site/.sass/lib/sass/logger/log_level.rb', line 23

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

- (Boolean) log_level?(level, min_level)

Returns:

  • (Boolean)


19
20
21
# File '/home/nweiz/code/sass-site/.sass/lib/sass/logger/log_level.rb', line 19

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