logger.rb does not rotate files properly

X

Xavier

I thought I'd mention that logger.rb does not rotate log files after it
has already rotated once. It does not set the sync flag to true when it
creates a new log file which means the stat.size call will always return 0
after the first rotation.
The following patch solves this issue:

$ diff -Nut /usr/lib/ruby/1.8/logger.rb ./logger.rb
--- /usr/lib/ruby/1.8/logger.rb 2004-02-07 11:05:12.000000000 +0100
+++ ./logger.rb 2004-04-14 20:55:25.617250444 +0200
@@ -539,6 +539,7 @@

def create_logfile(filename)
logdev = open(filename, (File::WRONLY | File::APPEND | File::CREAT))
+ logdev.sync = true
add_log_header(logdev)
logdev
end


hth
 
N

NAKAMURA, Hiroshi

Hi,
I thought I'd mention that logger.rb does not rotate log files after it
has already rotated once. It does not set the sync flag to true when it
creates a new log file which means the stat.size call will always return 0
after the first rotation.

I don't remember your first mail you mention here. Maybe I slipped a
message to ruby-bugs ML. And I'm very sorry for long silence.

I still don't understand the problem (weekly shifting seems to work for
me...), but I think anyway IO#sync = true is a must as you said. I'll
commit your path tonight.

Thank you for your patch and again apologize for not responding long time.

Regards,
// NaHi
 
X

Xavier

Hi,


I don't remember your first mail you mention here. Maybe I slipped a
message to ruby-bugs ML. And I'm very sorry for long silence.

What first email? That was my first post about this issue.
I still don't understand the problem (weekly shifting seems to work for
me...), but I think anyway IO#sync = true is a must as you said. I'll
commit your path tonight.
I've noticed it's been included a few days ago:
http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/lib/logger.rb.diff?r1=1.5.2.2;r2=1.5.2.3;f=h

Weekly rotations work because they do not need log file size.
Problem is rotation was done only once when based on size. Simply set a
small file size and start logging. The second log file, i.e. the first one
created by LogDevice::create_logfile did not have its sync flag raised and
would not be rotated because stat would return a 0-size. In other words,
you never got a 3rd log file.
Thank you for your patch and again apologize for not responding long
time.
No problem. I'm happy to see it's been solved.

Regards.
 
N

NAKAMURA, Hiroshi

Hi,
What first email? That was my first post about this issue.

Don't you submit this as a bug to jitterbug? I received a bug submit
notation as an e-mail.
I've noticed it's been included a few days ago:
http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/lib/logger.rb.diff?r1=1.5.2.2;r2=1.5.2.3;f=h

Doh. Thanks, matz. I only checked ChangeLog file.
Weekly rotations work because they do not need log file size.
Problem is rotation was done only once when based on size. Simply set a
small file size and start logging. The second log file, i.e. the first one
created by LogDevice::create_logfile did not have its sync flag raised and
would not be rotated because stat would return a 0-size. In other words,
you never got a 3rd log file.

I see the point. I didn't know sync and stat relation problem. Thank
you for pointing out it.

Regards,
// NaHi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top