Class: Spark::Fire
- Inherits:
-
Object
- Object
- Spark::Fire
- Defined in:
- lib/Spark/fire.rb
Overview
Spark logger functionality
Instance Attribute Summary collapse
-
#out ⇒ Object
readonly
returns the medium on where to print the error.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#error(message) ⇒ Object
Shows an error message.
-
#important(message) ⇒ Object
Show an important message in upper case.
-
#info(message) ⇒ Object
Shows an info message.
-
#initialize(out: $stdout, verbose: false) ⇒ Fire
constructor
Initialize with default stdout output and verbose false.
-
#log ⇒ Object
Gets the logging object.
-
#message(message) ⇒ Object
Shows a regular message.
-
#success(message) ⇒ Object
Shows a success message.
-
#warning(message) ⇒ Object
Shows a warning message.
Constructor Details
#initialize(out: $stdout, verbose: false) ⇒ Fire
Initialize with default stdout output and verbose false
11 12 13 14 |
# File 'lib/Spark/fire.rb', line 11 def initialize(out: $stdout, verbose: false) @out = out @verbose = verbose end |
Instance Attribute Details
#out ⇒ Object (readonly)
returns the medium on where to print the error
8 9 10 |
# File 'lib/Spark/fire.rb', line 8 def out @out end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
9 10 11 |
# File 'lib/Spark/fire.rb', line 9 def verbose @verbose end |
Instance Method Details
#error(message) ⇒ Object
Shows an error message
36 37 38 |
# File 'lib/Spark/fire.rb', line 36 def error() log.error(.to_s.red) end |
#important(message) ⇒ Object
Show an important message in upper case
41 42 43 |
# File 'lib/Spark/fire.rb', line 41 def important() log.warn(.to_s.upcase.magenta) end |
#info(message) ⇒ Object
Shows an info message
56 57 58 |
# File 'lib/Spark/fire.rb', line 56 def info() log.info(.to_s.blue) end |
#log ⇒ Object
Gets the logging object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/Spark/fire.rb', line 17 def log out.sync = true @log ||= Logger.new(out) @log.formatter = proc do |severity, datetime, progname, msg| if verbose string = "#{severity} [#{datetime.strftime('%Y-%m-%d %H:%M:%S.%2N')}]: " else string = "[#{datetime.strftime('%H:%M:%S')}]: " end string += "#{msg}\n" string end @log end |
#message(message) ⇒ Object
Shows a regular message
61 62 63 |
# File 'lib/Spark/fire.rb', line 61 def () log.info(.to_s) end |
#success(message) ⇒ Object
Shows a success message
51 52 53 |
# File 'lib/Spark/fire.rb', line 51 def success() log.info(.to_s.green) end |
#warning(message) ⇒ Object
Shows a warning message
46 47 48 |
# File 'lib/Spark/fire.rb', line 46 def warning() log.warn(.to_s.yellow) end |