[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sup-devel] How do I force flush the log file in sup?



On 30. juli 2013 15:18, Horacio Sanson wrote:
> Is there a way to force sup to flush the log file after each write? It is
> difficult to debug my gmail source as I cannot see real time what is going
> on. Maybe set sup to always flush when SUP_LOG_LEVEL is set to debug?

See below, you can add an check for log level as well if you want.

- gaute

diff --git a/lib/sup/logger.rb b/lib/sup/logger.rb
index 7dd296a..283dfdb 100644
--- a/lib/sup/logger.rb
+++ b/lib/sup/logger.rb
@@ -60,7 +60,10 @@ private
   ## actually distribute the message
   def send_message m
     @mutex.synchronize do
-      @sinks.each { |sink| sink << m }
+      @sinks.each do |sink|
+        sink << m
+        sink.flush if sink.respond_to? :flush
+      end
       @buf << m
     end
   end