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

Re: Log rotating - SIGALRM instead of SIGHUP and SIGUSR1



On Fri, 19 Apr 2002 21:36:15 +0200
Szeder Gabor <szeder@sch.bme.hu> wrote:

> Hi there!
> 
> There was a long thread about SIGHUP and its usage to rotate logfiles. I
> think SIGUSR1 is a better solution for this, but it's still the wrong
> solution. I think we shouldn't need any external program/script to make
> xchat to rotate the logs.
> 
> I took Ricardo B's SIGUSR1 patch and changed it to use SIGALRM and
> alarm() to rotate the logs at midnight. But there are several problems
> with this approach so I decided to use an other method. It's quite
> simple, too. This second one stores the  time of the next midnight in a
> variable. When some kind of message (eighter a PRIVMSG or a PING or etc.)
> arrives, it compares this variable with the time of the arrival of the 
> message. If the variable is smaller then it's time to rotate the logs. 
> Problems with this approach are: it will not happen exactly at midnight 
> but some time after midnight. I think this problem can be neglected,
> because there are no problems with multiple SIGALARMs or no need for
> additional scripts or external programs.
> 
> Both patches can be downloaded from:
> http://www.sch.bme.hu/~szeder/xchat.html
> And a brief description about my problems are also there. Please test it
> if you can!
> 
> Feel free to include it in x-chat. [But only after heavy testing!] (;
> 
> I plan to make it possible that the user will be able to set the time
> when the logfiles are to be rotated.
> 
> Regards,
> 
> Gabor Szeder

I think all your ideas are far too complicated. The simplest way to
rotate logs, is to add a new % for the current date. Then you simply compare
the filename that is produced, with the currently open filename. If they are
different, you re-open the log. You could then have a % for the day, another
% for the hour, and depending on the log mask used, it'll rotate the logs.
I'd save this for 1.9.x though.

-- 
Peter Zelezny. <zed@xchat.org>
--
XChat-discuss: mailing list for XChat users
Archive:       http://mail.nl.linux.org/xchat-discuss/