Class: FPM::Scriptable::Log
- Inherits:
-
Object
- Object
- FPM::Scriptable::Log
- Includes:
- Singleton
- Defined in:
- lib/fpm/scriptable/log.rb
Defined Under Namespace
Classes: LogHandler
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#has_error ⇒ Object
readonly
Returns the value of attribute has_error.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
Instance Method Summary collapse
- #add(level = :info, color = true, *args) ⇒ Object
- #clobber ⇒ Object
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #fatal(msg) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize ⇒ Log
constructor
A new instance of Log.
- #show(msg, quiet = @quiet) ⇒ Object
- #warn(msg) ⇒ Object
Constructor Details
#initialize ⇒ Log
Returns a new instance of Log.
22 23 24 |
# File 'lib/fpm/scriptable/log.rb', line 22 def initialize clobber end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
19 20 21 |
# File 'lib/fpm/scriptable/log.rb', line 19 def color @color end |
#has_error ⇒ Object (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 |
#quiet ⇒ Object
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
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fpm/scriptable/log.rb', line 40 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 |
#clobber ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/fpm/scriptable/log.rb', line 26 def clobber @quiet = false @color = true @logger = nil @has_error = false end |
#debug(msg) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/fpm/scriptable/log.rb', line 68 def debug(msg) if !msg.nil? if !@logger.nil? @logger.debug msg end end end |
#error(msg) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/fpm/scriptable/log.rb', line 76 def error(msg) @has_error = true if !msg.nil? if !@logger.nil? @logger.error msg end end end |
#fatal(msg) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/fpm/scriptable/log.rb', line 85 def fatal(msg) @has_error = true if !msg.nil? if !@logger.nil? @logger.fatal msg end end end |
#info(msg) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/fpm/scriptable/log.rb', line 52 def info(msg) if !msg.nil? if !@logger.nil? @logger.info msg end end end |
#show(msg, quiet = @quiet) ⇒ Object
34 35 36 37 38 |
# File 'lib/fpm/scriptable/log.rb', line 34 def show(msg,quiet=@quiet) if !msg.nil? puts msg unless quiet end end |
#warn(msg) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/fpm/scriptable/log.rb', line 60 def warn(msg) if !msg.nil? if !@logger.nil? @logger.warn msg end end end |