lib/td/logger/td_logger.rb in td-logger-0.3.22 vs lib/td/logger/td_logger.rb in td-logger-0.3.23
- old
+ new
@@ -96,9 +96,28 @@
end
}
end
end
+ def flush
+ @mutex.lock
+
+ # Move small chunks into queue to flush all events.
+ # See try_flush routine for more detail
+ @map.reject! {|(db,table),buffer|
+ data = buffer.flush!
+ @queue << [db, table, data]
+ }
+ try_flush
+ rescue => e
+ @logger.error "Unexpected error at flush: #{e}"
+ e.backtrace.each {|bt|
+ @logger.info bt
+ }
+ ensure
+ @mutex.unlock
+ end
+
def post_with_time(tag, record, time)
@logger.debug { "event: #{tag} #{record.to_json}" rescue nil }
record[:time] ||= time.to_i