Class: FPM::Scriptable::Log

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/fpm/scriptable/log.rb

Defined Under Namespace

Classes: LogHandler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLog

Returns a new instance of Log.



22
23
24
25
26
27
28
# File 'lib/fpm/scriptable/log.rb', line 22

def initialize
  @quiet = false
  @color = true

  @logger = nil
  @has_error = false
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



19
20
21
# File 'lib/fpm/scriptable/log.rb', line 19

def color
  @color
end

#has_errorObject (readonly)

Returns the value of attribute has_error.



20
21
22
# File 'lib/fpm/scriptable/log.rb', line 20

def has_error
  @has_error
end

#quietObject

Returns the value of attribute quiet.



19
20
21
# File 'lib/fpm/scriptable/log.rb', line 19

def quiet
  @quiet
end

Instance Method Details

#add(level = :info, color = true, *args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fpm/scriptable/log.rb', line 36

def add(level=:info, color=true, *args)
  l = LogHandler.new(*args)
  l.level = LogHandler.level level
  l.color = color

  if @logger.nil?
    @logger = l
  else
    @logger.extend(LogHandler.broadcast(l))
  end
end

#debug(msg) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/fpm/scriptable/log.rb', line 64

def debug(msg)
  if !msg.nil?
    if !@logger.nil?
      @logger.debug msg
    end
  end
end

#error(msg) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/fpm/scriptable/log.rb', line 72

def error(msg)
  @has_error = true
  if !msg.nil?
    if !@logger.nil?
      @logger.error msg
    end
  end
end

#fatal(msg) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/fpm/scriptable/log.rb', line 81

def fatal(msg)
  @has_error = true
  if !msg.nil?
    if !@logger.nil?
      @logger.fatal msg
    end
  end
end

#info(msg) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/fpm/scriptable/log.rb', line 48

def info(msg)
  if !msg.nil?
    if !@logger.nil?
      @logger.info msg
    end
  end
end

#show(msg, quiet = @quiet) ⇒ Object



30
31
32
33
34
# File 'lib/fpm/scriptable/log.rb', line 30

def show(msg,quiet=@quiet)
  if !msg.nil?
    puts msg unless quiet
  end
end

#warn(msg) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/fpm/scriptable/log.rb', line 56

def warn(msg)
  if !msg.nil?
    if !@logger.nil?
      @logger.warn msg
    end
  end
end