[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?
- To: Sup developer discussion <sup-devel@rubyforge.org>
- Subject: Re: [sup-devel] How do I force flush the log file in sup?
- From: Gaute Hope <eg@gaute.vetsj.com>
- Date: Sat, 10 Aug 2013 00:18:56 +0200
- Cc: Horacio Sanson <hsanson@gmail.com>
- In-reply-to: <CAHWBo_bM_WmaUUHbER+1V8=o_McxibJCCipnxKnepsviV8Rrhw@mail.gmail.com>
- References: <CAHWBo_bM_WmaUUHbER+1V8=o_McxibJCCipnxKnepsviV8Rrhw@mail.gmail.com>
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7
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