Changeset c1888a5 in code


Ignore:
Timestamp:
Mar 5, 2014, 11:04:58 PM (11 years ago)
Author:
Florian Obser <florian@…>
Branches:
master
Children:
9a2a703
Parents:
23ca6f1
Message:

rotate logs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • logger.c

    r23ca6f1 rc1888a5  
    239239logger_setts(void)
    240240{
     241        static int last_mon = -1;
    241242        struct tm *tm;
    242243        time_t t;
     244        int i;
    243245
    244246        time(&t);
    245247        tm = gmtime(&t);
    246         snprintf(file_ts, sizeof file_ts, "%04d-%02d", tm->tm_year + 1900,
    247             tm->tm_mon + 1);
     248        if (last_mon != tm->tm_mon) {
     249                snprintf(file_ts, sizeof file_ts, "%04d-%02d", tm->tm_year +
     250                    1900, tm->tm_mon + 1);
     251                last_mon = tm->tm_mon;
     252                for (i = 0; i < nlogfiles; i++) {
     253                        fclose(logfiles[i].fp);
     254                        logfiles[i].fp = NULL;
     255                }
     256                nlogfiles = 0;
     257        }
    248258        snprintf(line_ts, sizeof line_ts, "[%02d:%02d] ", tm->tm_hour,
    249259            tm->tm_min);
Note: See TracChangeset for help on using the changeset viewer.