]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
config: Use log_file from conf struct
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 16 Jul 2011 15:57:52 +0000 (17:57 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 20 Jul 2011 21:31:36 +0000 (23:31 +0200)
ccache.c
stats.c
test/framework.c
util.c

index 0deaaf42b02743723c3d178c269a0263a9cb1bc0..45d214be64ce7fccd0b96e8a9cda0a064d86397e 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -76,9 +76,6 @@ struct conf *conf = NULL;
 /* current working directory taken from $PWD, or getcwd() if $PWD is bad */
 char *current_working_dir = NULL;
 
-/* the debug logfile name, if set */
-char *cache_logfile = NULL;
-
 /* the original argument list */
 static struct args *orig_args;
 
@@ -1829,8 +1826,6 @@ initialize(void)
        exitfn_add_nullary(stats_flush);
        exitfn_add_nullary(clean_up_tmp_files);
 
-       /* check for logging early so cc_log messages start working ASAP */
-       cache_logfile = getenv("CCACHE_LOGFILE");
        cc_log("=== CCACHE STARTED =========================================");
 
        /* the user might have set CCACHE_UMASK */
@@ -1853,7 +1848,6 @@ cc_reset(void)
 {
        conf_free(conf); conf = NULL;
        free(current_working_dir); current_working_dir = NULL;
-       cache_logfile = NULL;
        args_free(orig_args); orig_args = NULL;
        free(input_file); input_file = NULL;
        free(output_obj); output_obj = NULL;
diff --git a/stats.c b/stats.c
index 511456900cfa26d3e7300663893bbc9292a9f3ec..3d02c2d693306f86bcf84c844de462b273ff35d8 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -204,7 +204,6 @@ stats_flush(void)
        bool need_cleanup = false;
        bool should_flush = false;
        int i;
-       extern char *cache_logfile;
 
        if (getenv("CCACHE_NOSTATS")) return;
 
@@ -225,6 +224,7 @@ stats_flush(void)
                 * A NULL stats_file means that we didn't get past calculate_object_hash(),
                 * so we just choose one of stats files in the 16 subdirectories.
                 */
+               assert(conf);
                stats_dir = format("%s/%x", conf->cache_dir, hash_from_int(getpid()) % 16);
                stats_file = format("%s/stats", stats_dir);
                free(stats_dir);
@@ -241,7 +241,7 @@ stats_flush(void)
        stats_write(stats_file, counters);
        lockfile_release(stats_file);
 
-       if (cache_logfile) {
+       if (!str_eq(conf->log_file, "")) {
                for (i = 0; i < STATS_END; ++i) {
                        if (counter_updates->data[stats_info[i].stat] != 0
                            && !(stats_info[i].flags & FLAG_NOZERO)) {
index c366afeec72059888508a150811534ab3a0405e8..85b4bd4b1408ea14a93d5e819fbd56fd62251fd2 100644 (file)
@@ -115,8 +115,6 @@ cct_suite_end()
 void
 cct_test_begin(const char *name)
 {
-       extern char *cache_logfile;
-
        ++total_tests;
        if (verbose) {
                printf("--- TEST: %s ---\n", name);
@@ -128,7 +126,6 @@ cct_test_begin(const char *name)
 
        putenv("CCACHE_CONFIG_PATH=/dev/null");
        cc_reset();
-       cache_logfile = getenv("CCACHE_LOGFILE");
 }
 
 void
diff --git a/util.c b/util.c
index 810ccc7fb446c2f2913a48f8f6e5e7ad6be9d7a8..6f8b35f7f16675c8c38e2887a0e4e23ec417a22b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -18,6 +18,7 @@
  */
 
 #include "ccache.h"
+#include "conf.h"
 
 #include <zlib.h>
 
@@ -38,15 +39,16 @@ static FILE *logfile;
 static bool
 init_log(void)
 {
-       extern char *cache_logfile;
+       extern struct conf *conf;
 
        if (logfile) {
                return true;
        }
-       if (!cache_logfile) {
+       assert(conf);
+       if (str_eq(conf->log_file, "")) {
                return false;
        }
-       logfile = fopen(cache_logfile, "a");
+       logfile = fopen(conf->log_file, "a");
        if (logfile) {
                return true;
        } else {