]> git.proxmox.com Git - pve-sheepdog.git/blob - debian/patches/simplify-log-rotation.patch
Simplify logfile rotation
[pve-sheepdog.git] / debian / patches / simplify-log-rotation.patch
1 simplify logfile rotation
2
3 we simply rename <logfile> to <logfile>.1. That way we do not need
4 any logrotate script. max_logfile is set to 256MB.
5
6
7 Index: new/lib/logger.c
8 ===================================================================
9 --- new.orig/lib/logger.c 2012-07-17 14:40:47.000000000 +0200
10 +++ new/lib/logger.c 2012-07-17 14:42:16.000000000 +0200
11 @@ -57,7 +57,7 @@
12 static pid_t logger_pid;
13 static key_t semkey;
14
15 -static int64_t max_logsize = 500 * 1024 * 1024; /*500MB*/
16 +static int64_t max_logsize = 256 * 1024 * 1024; /*256MB*/
17
18 pthread_mutex_t logsize_lock = PTHREAD_MUTEX_INITIALIZER;
19
20 @@ -345,13 +345,7 @@
21
22 if (access(log_nowname, R_OK) == 0) {
23 char old_logfile[256];
24 - time_t t;
25 - struct tm tm;
26 - time(&t);
27 - localtime_r((const time_t *)&t, &tm);
28 - sprintf(old_logfile, "%s.%04d-%02d-%02d-%02d-%02d",
29 - log_nowname, tm.tm_year + 1900, tm.tm_mon + 1,
30 - tm.tm_mday, tm.tm_hour, tm.tm_min);
31 + sprintf(old_logfile, "%s.1", log_nowname);
32 rename(log_nowname, old_logfile);
33 }
34 new_fd = open(log_nowname, O_RDWR | O_CREAT | O_APPEND, 0644);