]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
cleanup: Improve logging
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 4 Jan 2018 21:55:58 +0000 (22:55 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 10 Jan 2018 19:58:32 +0000 (20:58 +0100)
cleanup.c
stats.c

index 428a64b52b4dcb5072833c5d14f18938dc976e08..f6f363f1f3f62be5111cb4d1d2a871ee3354ce07 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -1,5 +1,5 @@
 // Copyright (C) 2002-2006 Andrew Tridgell
-// Copyright (C) 2009-2016 Joel Rosdahl
+// Copyright (C) 2009-2018 Joel Rosdahl
 //
 // This program is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by the Free
@@ -194,6 +194,9 @@ cleanup_dir(struct conf *conf, const char *dir)
                stats_add_cleanup(dir, 1);
        }
 
+       cc_log("After cleanup: %lu KiB, %zu files",
+              (unsigned long)cache_size / 1024,
+              files_in_cache);
        stats_set_sizes(dir, files_in_cache, cache_size);
 
        // Free it up.
diff --git a/stats.c b/stats.c
index 5d9fc737885001b5ff822be01eccd481c3105226..4576c3c516fb9f6dbc58714f704c8d6867e30d2c 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -1,5 +1,5 @@
 // Copyright (C) 2002-2004 Andrew Tridgell
-// Copyright (C) 2009-2016 Joel Rosdahl
+// Copyright (C) 2009-2018 Joel Rosdahl
 //
 // This program is free software; you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by the Free
@@ -374,22 +374,31 @@ stats_flush(void)
                }
        }
 
+       char *subdir = dirname(stats_file);
        bool need_cleanup = false;
+
        if (conf->max_files != 0
            && counters->data[STATS_NUMFILES] > conf->max_files / 16) {
+               cc_log("Need to clean up %s since it holds %u files (limit: %u files)",
+                      subdir,
+                      counters->data[STATS_NUMFILES],
+                      conf->max_files / 16);
                need_cleanup = true;
        }
        if (conf->max_size != 0
            && counters->data[STATS_TOTALSIZE] > conf->max_size / 1024 / 16) {
+               cc_log("Need to clean up %s since it holds %u KiB (limit: %lu KiB)",
+                      subdir,
+                      counters->data[STATS_TOTALSIZE],
+                      (unsigned long)conf->max_size / 1024 / 16);
                need_cleanup = true;
        }
 
        if (need_cleanup) {
-               char *p = dirname(stats_file);
-               cleanup_dir(conf, p);
-               free(p);
+               cleanup_dir(conf, subdir);
        }
 
+       free(subdir);
        counters_free(counters);
 }