about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-03 09:20:42 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-03 09:20:42 -0700
commitb7c6846e317b0f2bfe4807aab34524c2a633947c (patch)
tree013a4590fada5dd821b5f85a376d54ffda7897b8 /lib
parentafaa8efb31094a831a68b383523f9bac46a244ac (diff)
downloadclogger-b7c6846e317b0f2bfe4807aab34524c2a633947c.tar.gz
Userspace buffering defaults are dangerous as the Ruby default
IO objects do not do line-aware buffering.  This makes the
README examples with File.open much safer to use out-of-the-box
for users of the pure-Ruby version.  For users on the MRI C
extension logging to regular files, this should not have any
effect as we've optimized those to do unbuffered write(2)
syscalls anyways.
Diffstat (limited to 'lib')
-rw-r--r--lib/clogger/pure.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/clogger/pure.rb b/lib/clogger/pure.rb
index d8752b3..57e727b 100644
--- a/lib/clogger/pure.rb
+++ b/lib/clogger/pure.rb
@@ -8,6 +8,7 @@ class Clogger
   def initialize(app, opts = {})
     @app = app
     @logger = opts[:logger]
+    (@logger.sync = true) rescue nil
     @fmt_ops = compile_format(opts[:format] || Format::Common)
     @wrap_body = need_wrap_body?(@fmt_ops)
     @reentrant = nil