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

Commit1a6ee7a

Browse files
committed
Rotation by size works
1 parentcfe9b85 commit1a6ee7a

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎utils/logger.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,33 @@ static void
329329
open_logfile(FILE**file,constchar*filename_format)
330330
{
331331
char*filename;
332+
structstatst;
333+
boolrotation_requested= false;
332334

333335
filename=logfile_getname(filename_format,time(NULL));
334-
*file=logfile_open(filename,"a");
336+
337+
/* First check for rotation by size */
338+
if (log_rotation_size>0)
339+
{
340+
if (stat(filename,&st)==-1)
341+
{
342+
if (errno==ENOENT)
343+
{
344+
/* There is no file "filename" and rotation does not need */
345+
}
346+
else
347+
elog(ERROR,"cannot stat log file \"%s\": %s",
348+
filename,strerror(errno));
349+
}
350+
/* Found log file "filename" */
351+
else
352+
rotation_requested= (st.st_size >=log_rotation_size*1024L);
353+
}
354+
355+
if (rotation_requested)
356+
*file=logfile_open(filename,"w");
357+
else
358+
*file=logfile_open(filename,"a");
335359
pfree(filename);
336360

337361
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp