]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Print the time when stats last updated
authorAnders F Björklund <anders.f.bjorklund@gmail.com>
Mon, 9 Apr 2018 18:35:25 +0000 (20:35 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 23 Apr 2018 20:04:47 +0000 (22:04 +0200)
src/stats.c

index 5ac56fdc229aff2d5bd4a27abcbb07cea92f9b36..6c81d2dcc0b76fa6d997f71b70712b37ee507f78 100644 (file)
@@ -445,6 +445,8 @@ stats_summary(struct conf *conf)
 {
        struct counters *counters = counters_init(STATS_END);
        time_t oldest = 0;
+       time_t updated = 0;
+       struct stat st;
 
        assert(conf);
 
@@ -464,6 +466,11 @@ stats_summary(struct conf *conf)
                if (current != 0 && (oldest == 0 || current < oldest)) {
                        oldest = current;
                }
+               if (stat(fname, &st) == 0) {
+                       if (st.st_mtime > updated) {
+                               updated = st.st_mtime;
+                       }
+               }
                free(fname);
        }
 
@@ -478,6 +485,12 @@ stats_summary(struct conf *conf)
                strftime(timestamp, sizeof(timestamp), "%c", tm);
                printf("stats zero time                     %s\n", timestamp);
        }
+       if (updated) {
+               struct tm *tm = localtime(&updated);
+               char timestamp[100];
+               strftime(timestamp, sizeof(timestamp), "%c", tm);
+               printf("stats updated                       %s\n", timestamp);
+       }
 
        // ...and display them.
        for (int i = 0; stats_info[i].message; i++) {