mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
log rotation re-implemented
This commit is contained in:
parent
f219544d6a
commit
ee8cdbc85b
12
src/log.c
12
src/log.c
@ -123,6 +123,12 @@ static void delayflushlogs(void){
|
||||
struct LOGGER *log;
|
||||
for(log = loggers; log; log=log->next){
|
||||
if(log->logfunc && log->logfunc->flush)log->logfunc->flush(log);
|
||||
#ifndef WITHMAIN
|
||||
if(log->rotate && log->logfunc && log->logfunc->rotate && timechanged(log->rotated, conf.time, log->rotate)){
|
||||
log->logfunc->rotate(log);
|
||||
log->rotated = conf.time;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,6 +151,7 @@ void delayregisterlog(struct LOGGER *log){
|
||||
if(!strncmp(log->selector, funcs->prefix, strlen(funcs->prefix))){
|
||||
if(funcs->init && funcs->init(log)) break;
|
||||
log->logfunc = funcs;
|
||||
log->rotated = conf.time;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -495,10 +502,7 @@ unsigned char * dologname (unsigned char *buf, int bufsize, unsigned char *name
|
||||
|
||||
ts = localtime(&t);
|
||||
if(strchr((char *)name, '%')){
|
||||
struct clientparam fakecli;
|
||||
|
||||
memset(&fakecli, 0, sizeof(fakecli));
|
||||
dobuf2(&fakecli, buf, bufsize - strlen(ext), NULL, NULL, ts, (char *)name);
|
||||
dobuf2(&logparam, buf, bufsize - (ext?strlen(ext):0), NULL, NULL, ts, (char *)name);
|
||||
}
|
||||
else switch(lt){
|
||||
case NONE:
|
||||
|
@ -197,6 +197,7 @@ void clearstat(struct clientparam * param);
|
||||
void dumpcounters(struct trafcount *tl, int counterd);
|
||||
int startconnlims (struct clientparam *param);
|
||||
void stopconnlims (struct clientparam *param);
|
||||
int timechanged (time_t oldtime, time_t newtime, ROTATION lt);
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user