Class: Sass::Logger::Base

Inherits:
Object
  • Object
show all
Includes:
LogLevel
Defined in:
.ruby-sass/lib/sass/logger/base.rb

Direct Known Subclasses

Delayed

Direct Known Subclasses

Delayed

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from LogLevel

included

Constructor Details

#initialize(log_level = :debug, io = nil) ⇒ Base

Returns a new instance of Base



16
17
18
19
# File '.ruby-sass/lib/sass/logger/base.rb', line 16

def initialize(log_level = :debug, io = nil)
  self.log_level = log_level
  self.io = io
end

Constructor Details

#initialize(log_level = :debug, io = nil) ⇒ Base

Returns a new instance of Base



16
17
18
19
# File '.ruby-sass/lib/sass/logger/base.rb', line 16

def initialize(log_level = :debug, io = nil)
  self.log_level = log_level
  self.io = io
end

Instance Attribute Details

#disabledObject

Returns the value of attribute disabled



7
8
9
# File '.ruby-sass/lib/sass/logger/base.rb', line 7

def disabled
  @disabled
end

#ioObject

Returns the value of attribute io



8
9
10
# File '.ruby-sass/lib/sass/logger/base.rb', line 8

def io
  @io
end

#log_levelObject

Returns the value of attribute log_level



6
7
8
# File '.ruby-sass/lib/sass/logger/base.rb', line 6

def log_level
  @log_level
end

Instance Method Details

#_log(level, message) ⇒ Object



40
41
42
43
44
45
46
# File '.ruby-sass/lib/sass/logger/base.rb', line 40

def _log(level, message)
  if io
    io.puts(message)
  else
    Kernel.warn(message)
  end
end

#captureObject

Captures all logger messages emitted during a block and returns them as a string.



27
28
29
30
31
32
33
34
# File '.ruby-sass/lib/sass/logger/base.rb', line 27

def capture
  old_io = io
  self.io = StringIO.new
  yield
  io.string
ensure
  self.io = old_io
end

#log(level, message) ⇒ Object



36
37
38
# File '.ruby-sass/lib/sass/logger/base.rb', line 36

def log(level, message)
  _log(level, message) if logging_level?(level)
end

#logging_level?(level) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File '.ruby-sass/lib/sass/logger/base.rb', line 21

def logging_level?(level)
  !disabled && self.class.log_level?(level, log_level)
end