]> git.proxmox.com Git - pve-sheepdog.git/blame - debian/patches/simplify-log-rotation.patch
bump to 0.5.6
[pve-sheepdog.git] / debian / patches / simplify-log-rotation.patch
CommitLineData
2bfaf47b
DM
1simplify logfile rotation
2
3we simply rename <logfile> to <logfile>.1. That way we do not need
4any logrotate script. max_logfile is set to 256MB.
5
6
7Index: new/lib/logger.c
8===================================================================
3c2bee59
AD
9--- a/lib/logger.c
10+++ b/lib/logger.c
11@@ -97,7 +97,7 @@ static pid_t logger_pid;
2bfaf47b 12 static key_t semkey;
3c2bee59 13 static char *log_buff;
2bfaf47b
DM
14
15-static int64_t max_logsize = 500 * 1024 * 1024; /*500MB*/
3c2bee59 16+static int64_t max_logsize = 256 * 1024 * 1024; /*500MB*/
2bfaf47b 17
3c2bee59 18 static pthread_mutex_t logsize_lock = PTHREAD_MUTEX_INITIALIZER;
2bfaf47b 19
3c2bee59 20@@ -357,14 +357,7 @@ static notrace void rotate_log(void)
2bfaf47b
DM
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);
3c2bee59
AD
28- snprintf(old_logfile, sizeof(old_logfile),
29- "%s.%04d-%02d-%02d-%02d-%02d",
30- log_nowname, tm.tm_year + 1900, tm.tm_mon + 1,
31- tm.tm_mday, tm.tm_hour, tm.tm_min);
2bfaf47b
DM
32+ sprintf(old_logfile, "%s.1", log_nowname);
33 rename(log_nowname, old_logfile);
34 }
35 new_fd = open(log_nowname, O_RDWR | O_CREAT | O_APPEND, 0644);