Class: AjaxCat::Logger
- Inherits:
-
Object
- Object
- AjaxCat::Logger
- Defined in:
- lib/ajax-cat/logger.rb
Constant Summary collapse
- @@print =
true
Class Method Summary collapse
Instance Method Summary collapse
- #compose_message(message) ⇒ Object
-
#initialize(prefix = false) ⇒ Logger
constructor
A new instance of Logger.
- #log(message) ⇒ Object
Constructor Details
#initialize(prefix = false) ⇒ Logger
Returns a new instance of Logger.
10 11 12 |
# File 'lib/ajax-cat/logger.rb', line 10 def initialize(prefix = false) @prefix = prefix end |
Class Method Details
.print_log(val) ⇒ Object
6 7 8 |
# File 'lib/ajax-cat/logger.rb', line 6 def self.print_log(val) @@print = val end |
Instance Method Details
#compose_message(message) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ajax-cat/logger.rb', line 19 def () t = Time.now milliseconds = (t.to_f * 1000 % 1000).to_i ret = (t.strftime("%Y-%d-%m %H:%M:%S.#{milliseconds}") + " ") (3 - milliseconds.to_s.length).times {ret += " "} if @prefix ret = "#{ret}#{@prefix.red}: #{}" else ret = "#{ret}#{.green}" end ret end |
#log(message) ⇒ Object
14 15 16 17 |
# File 'lib/ajax-cat/logger.rb', line 14 def log() return unless @@print puts () end |