4 ms·
ActiveSupport::BufferedLogger#auto_flushing is deprecated. Either set the sync level on the underlying file handle like this: f = File.open('foo.log
by jeltz 14y ago
ActiveSupport::BufferedLogger#auto_flushing is deprecated. Either set the
sync level on the underlying file handle like this:
f = File.open('foo.log', 'w')
f.sync = true
ActiveSupport::BufferedLogger.new f
Or tune your filesystem. The FS cache is now what controls flushing.
The above from the commit message is incorrect. IO#sync in ruby has nothing to with the filesystem cache, and only controls Ruby's own internal buffers. And as far as I can tell the logger in rails has sync = true by default anyway.
And disabling your filesystem cache at the OS level sounds like a terrible idea.
The commit message only makes sense if he actual talks about IO#fdatasync or he means that "f.sync = false" disables the new behavior.
- calinet6 14y agoInteresting. So does anyone know the rationale behind this change? I'm guessing there's actually a good reason and it's just eluding us because our logs are now messy and that appears to be bad.
- jeltz 14y agoThe change that should be there is that if you run multiple rails instances against the same log file you should for concurrent requests get interleaved lines since it is written line by line immediately to the file (though not necessarily flushed to the HDD). If you get scrambled lines (ie the contents of two lines can mix up) then I personally would see that as a bug. No change to IO#sync, IO#fdatasync or the filesystem settings should make it revert to the old behavior. If you set IO#sync to false it might seem like you get something like the old behviour back, but I think you risk scrambled lines since it will the flush when Ruby's buffer is full.