Class: RippleNetworks::WarningShot::Logger
- Inherits:
-
Object
- Object
- RippleNetworks::WarningShot::Logger
- Defined in:
- lib/warning_shot/logger.rb
Constant Summary collapse
- CLEAR =
`clear`
- ESCAPE_SEQ =
{ :notice => "\e[37m%s\e[0m", :warning => "\e[33m%s\e[0m", :debug => "\e[34m%s\e[0m", :error => "\e[31m%s\e[0m", :fatal => "\e[1m\e[5m%s\e[0m" }
- DEFAULTS =
{ :verbose => false, :flush => false }
Instance Method Summary collapse
- #close ⇒ Object
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #fatal(msg) ⇒ Object
- #heading(title = "") ⇒ Object
- #info(msg) ⇒ Object
-
#initialize(path, opts = {}) ⇒ Logger
constructor
A new instance of Logger.
- #notice(msg) ⇒ Object
- #warning(msg) ⇒ Object
Constructor Details
#initialize(path, opts = {}) ⇒ Logger
Returns a new instance of Logger.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/warning_shot/logger.rb', line 32 def initialize(path,opts={}) = DEFAULTS.merge(opts) @verbose = [:verbose] @log_file = File.open(path,"a+") #Flush log flush_log!(path) if [:flush] #Clear console puts CLEAR if @verbose end |
Instance Method Details
#close ⇒ Object
51 52 53 |
# File 'lib/warning_shot/logger.rb', line 51 def close() @log_file.close unless @log_file.closed? end |
#debug(msg) ⇒ Object
66 67 68 69 70 |
# File 'lib/warning_shot/logger.rb', line 66 def debug(msg) frm_msg = output_msg(:debug,msg) @log_file.puts frm_msg puts frm_msg if @verbose end |
#error(msg) ⇒ Object
72 73 74 75 76 |
# File 'lib/warning_shot/logger.rb', line 72 def error(msg) frm_msg = output_msg(:error,msg) @log_file.puts frm_msg puts frm_msg if @verbose end |
#fatal(msg) ⇒ Object
84 85 86 87 88 |
# File 'lib/warning_shot/logger.rb', line 84 def fatal(msg) frm_msg = output_msg(:fatal,msg) @log_file.puts frm_msg puts frm_msg if @verbose end |
#heading(title = "") ⇒ Object
45 46 47 48 49 |
# File 'lib/warning_shot/logger.rb', line 45 def heading(title=""); msg = %{#{title.center(60,"-") }} @log_file.puts msg puts msg if @verbose end |
#info(msg) ⇒ Object
55 56 57 58 |
# File 'lib/warning_shot/logger.rb', line 55 def info(msg) @log_file.puts msg puts msg if @verbose end |
#notice(msg) ⇒ Object
60 61 62 63 64 |
# File 'lib/warning_shot/logger.rb', line 60 def notice(msg) frm_msg = output_msg(:notice,msg) @log_file.puts frm_msg puts frm_msg if @verbose end |
#warning(msg) ⇒ Object
78 79 80 81 82 |
# File 'lib/warning_shot/logger.rb', line 78 def warning(msg) frm_msg = output_msg(:warning,msg) @log_file.puts frm_msg puts frm_msg if @verbose end |