Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite56ae30

Browse files
committed
Working on log_rotation_age
1 parent1a6ee7a commite56ae30

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

‎utils/logger.c‎

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,29 +329,59 @@ static void
329329
open_logfile(FILE**file,constchar*filename_format)
330330
{
331331
char*filename;
332-
structstatst;
332+
structstatst;
333333
boolrotation_requested= false;
334334

335335
filename=logfile_getname(filename_format,time(NULL));
336336

337-
/* First check for rotationby size*/
338-
if (log_rotation_size>0)
337+
/* First check for rotation */
338+
if (log_rotation_size>0||log_rotation_age>0)
339339
{
340340
if (stat(filename,&st)==-1)
341341
{
342342
if (errno==ENOENT)
343343
{
344344
/* There is no file "filename" and rotation does not need */
345+
gotologfile_open;
345346
}
346347
else
347348
elog(ERROR,"cannot stat log file \"%s\": %s",
348349
filename,strerror(errno));
349350
}
350351
/* Found log file "filename" */
351-
else
352+
353+
/* Check for rotation by age */
354+
if (log_rotation_age>0)
355+
{
356+
charcontrol[MAXPGPATH];
357+
structstatcontrol_st;
358+
FILE*control_file;
359+
360+
snprintf(control,MAXPGPATH,"%s.rotation",filename);
361+
if (stat(control,&control_st)==-1)
362+
{
363+
if (errno==ENOENT)
364+
{
365+
/* There is no control file for rotation */
366+
gotologfile_open;
367+
}
368+
else
369+
elog(ERROR,"cannot stat rotation file \"%s\": %s",
370+
control,strerror(errno));
371+
}
372+
373+
/* Found control file for rotation */
374+
375+
control_file=fopen(control,"r");
376+
fclose(control_file);
377+
}
378+
379+
/* Check for rotation by size */
380+
if (!rotation_requested&&log_rotation_size>0)
352381
rotation_requested= (st.st_size >=log_rotation_size*1024L);
353382
}
354383

384+
logfile_open:
355385
if (rotation_requested)
356386
*file=logfile_open(filename,"w");
357387
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp