Class: OLogger::Buffer
- Inherits:
-
Object
- Object
- OLogger::Buffer
- Defined in:
- lib/ologger/buffer.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
Returns the value of attribute messages.
Instance Method Summary collapse
- #add(options = {}) ⇒ Object
- #flush ⇒ Object
- #grouped_messages ⇒ Object
-
#initialize ⇒ Buffer
constructor
A new instance of Buffer.
- #write ⇒ Object
Constructor Details
#initialize ⇒ Buffer
Returns a new instance of Buffer.
5 6 7 |
# File 'lib/ologger/buffer.rb', line 5 def initialize self. = [] end |
Instance Attribute Details
#messages ⇒ Object
Returns the value of attribute messages.
3 4 5 |
# File 'lib/ologger/buffer.rb', line 3 def @messages end |
Instance Method Details
#add(options = {}) ⇒ Object
13 14 15 |
# File 'lib/ologger/buffer.rb', line 13 def add( = {}) << end |
#flush ⇒ Object
9 10 11 |
# File 'lib/ologger/buffer.rb', line 9 def flush self. = [] end |
#grouped_messages ⇒ Object
17 18 19 |
# File 'lib/ologger/buffer.rb', line 17 def .group_by { |b| "#{b[:logger_module]}.#{b[:logger_id]}"} end |
#write ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ologger/buffer.rb', line 21 def write .each do |k, | logger_module = .first[:logger_module] || 'unknown' logger_id = .first[:logger_id] || 'unknown' OLogger.create_module(logger_module) (OLogger.path + logger_module + (logger_id.to_s + '.log')).open('a+') do |file| .each do || file.puts "#{Time.now.strftime('%d.%m.%Y %H:%M:%S')}: #{[:message]}" [:objs].each { |obj| PP.pp(obj, file) } if [:objs] end end end end |