Class: Jekyll::Stevenson

Inherits:
Logger
  • Object
show all
Defined in:
lib/jekyll/stevenson.rb

Instance Method Summary collapse

Constructor Details

#initializeStevenson

Returns a new instance of Stevenson



5
6
7
8
9
10
11
12
13
# File 'lib/jekyll/stevenson.rb', line 5

def initialize
  @progname = nil
  @level = DEBUG
  @default_formatter = Formatter.new
  @logdev = $stdout
  @formatter = proc do |_, _, _, msg|
    msg.to_s
  end
end

Instance Method Details

#add(severity, message = nil, progname = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jekyll/stevenson.rb', line 15

def add(severity, message = nil, progname = nil)
  severity ||= UNKNOWN
  @logdev = logdevice(severity)

  if @logdev.nil? || severity < @level
    return true
  end
  progname ||= @progname
  if message.nil?
    if block_given?
      message = yield
    else
      message = progname
      progname = @progname
    end
  end
  @logdev.puts(
    format_message(format_severity(severity), Time.now, progname, message)
  )
  true
end

#closeObject



47
48
49
# File 'lib/jekyll/stevenson.rb', line 47

def close
  # No LogDevice in use
end

#error(progname = nil, &block) ⇒ Object

Log an ERROR message



43
44
45
# File 'lib/jekyll/stevenson.rb', line 43

def error(progname = nil, &block)
  add(ERROR, nil, progname.red, &block)
end

#warn(progname = nil, &block) ⇒ Object

Log a WARN message



38
39
40
# File 'lib/jekyll/stevenson.rb', line 38

def warn(progname = nil, &block)
  add(WARN, nil, progname.yellow, &block)
end