]>
Commit | Line | Data |
---|---|---|
27a9d69f ER |
1 | set sane format for archived logs, so the files would be sortable |
2 | ideally this should came from config (date_format=iso8601) | |
3 | ||
4ad96cc5 ER |
4 | --- nagios-3.4.1/base/logging.c~ 2012-05-24 17:09:34.000000000 +0300 |
5 | +++ nagios-3.4.1/base/logging.c 2012-05-24 17:10:09.466859755 +0300 | |
6 | @@ -424,7 +424,7 @@ | |
27a9d69f ER |
7 | stat_result = stat(log_file, &log_file_stat); |
8 | ||
9 | /* get the archived filename to use */ | |
4ad96cc5 ER |
10 | - asprintf(&log_archive, "%s%snagios-%02d-%02d-%d-%02d.log", log_archive_path, (log_archive_path[strlen(log_archive_path) - 1] == '/') ? "" : "/", t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour); |
11 | + asprintf(&log_archive," %s%snagios-%04d-%02d-%02d-%02d.log", log_archive_path, (log_archive_path[strlen(log_archive_path) - 1] == '/') ? "" : "/", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour); | |
12 | ||
27a9d69f | 13 | /* rotate the log file */ |
f9ffdd32 | 14 | rename_result = my_rename(log_file, log_archive); |
4ad96cc5 ER |
15 | --- nagios-3.4.1/cgi/cgiutils.c~ 2012-05-24 17:09:34.000000000 +0300 |
16 | +++ nagios-3.4.1/cgi/cgiutils.c 2012-05-24 17:11:08.629380008 +0300 | |
17 | @@ -1143,7 +1143,7 @@ | |
f9ffdd32 | 18 | t = localtime(&this_scheduled_log_rotation); |
27a9d69f ER |
19 | |
20 | /* use the time that the log rotation occurred to figure out the name of the log file */ | |
f9ffdd32 | 21 | - snprintf(buffer, buffer_length, "%snagios-%02d-%02d-%d-%02d.log", log_archive_path, t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour); |
22 | + snprintf(buffer, buffer_length, "%snagios-%04d-%02d-%02d-%02d.log", log_archive_path, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour); | |
4ad96cc5 | 23 | buffer[buffer_length - 1] = '\x0'; |
27a9d69f ER |
24 | |
25 | return; |