]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Improve log messages
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 24 Feb 2010 19:55:06 +0000 (20:55 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 24 Feb 2010 20:39:35 +0000 (21:39 +0100)
ccache.c
execute.c
manifest.c
stats.c
util.c

index 324cb1f587b3acdde9569fd4a95e0ff0d68c0535..5624f3fff537dae0a4b8751e43ad6a787b71f200 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -253,7 +253,7 @@ static char *get_path_in_cache(const char *name, const char *suffix,
                free(path);
                path = p;
                if (create_dir(path) != 0) {
-                       cc_log("failed to create %s", path);
+                       cc_log("Failed to create %s", path);
                        failed();
                }
        }
@@ -293,11 +293,11 @@ static void remember_include_file(char *path, size_t path_len)
        /* Let's hash the include file. */
        fd = open(path, O_RDONLY|O_BINARY);
        if (fd == -1) {
-               cc_log("Failed to open include file \"%s\"", path);
+               cc_log("Failed to open include file %s", path);
                goto failure;
        }
        if (fstat(fd, &st) != 0) {
-               cc_log("Failed to fstat include file \"%s\"", path);
+               cc_log("Failed to fstat include file %s", path);
                goto failure;
        }
        if (S_ISDIR(st.st_mode)) {
@@ -306,7 +306,7 @@ static void remember_include_file(char *path, size_t path_len)
        }
        if (st.st_mtime >= time_of_compilation
            || st.st_ctime >= time_of_compilation) {
-               cc_log("Include file \"%s\" too new", path);
+               cc_log("Include file %s too new", path);
                goto failure;
        }
        data = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -375,17 +375,17 @@ static int process_preprocessed_file(struct mdfour *hash, const char *path)
 
        fd = open(path, O_RDONLY);
        if (fd == -1) {
-               cc_log("failed to open %s", path);
+               cc_log("Failed to open %s", path);
                return 0;
        }
        if (fstat(fd, &st) != 0) {
-               cc_log("failed to fstat %s", path);
+               cc_log("Failed to fstat %s", path);
                return 0;
        }
        size = st.st_size;
        data = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
        if (data == (void *)-1) {
-               cc_log("failed to mmap %s", path);
+               cc_log("Failed to mmap %s", path);
                return 0;
        }
        close(fd);
@@ -409,7 +409,7 @@ static int process_preprocessed_file(struct mdfour *hash, const char *path)
                        }
                        q++;
                        if (q >= end) {
-                               cc_log("Failed parsing included file path");
+                               cc_log("Failed to parse included file path");
                                munmap(data, size);
                                return 0;
                        }
@@ -521,7 +521,8 @@ static void to_cache(ARGS *args)
 
        if (status != 0) {
                int fd;
-               cc_log("Compile of %s gave status = %d", output_obj, status);
+               cc_log("Compile of %s gave exit status %d",
+                      output_obj, status);
                stats_update(STATS_STATUS);
 
                fd = open(tmp_stderr, O_RDONLY | O_BINARY);
@@ -566,18 +567,21 @@ static void to_cache(ARGS *args)
        }
        if (st.st_size > 0) {
                if (move_file(tmp_stderr, cached_stderr, compress) != 0) {
-                       cc_log("Failed to move tmp stderr to the cache");
+                       cc_log("Failed to move %s to %s",
+                              tmp_stderr, cached_stderr);
                        stats_update(STATS_ERROR);
                        failed();
                }
-               cc_log("Stored stderr from the compiler in the cache");
+               cc_log("Stored in cache: %s", cached_stderr);
        } else {
                unlink(tmp_stderr);
        }
        if (move_file(tmp_obj, cached_obj, compress) != 0) {
-               cc_log("Failed to move tmp object file into the cache");
+               cc_log("Failed to move %s to %s", tmp_obj, cached_obj);
                stats_update(STATS_ERROR);
                failed();
+       } else {
+               cc_log("Stored in cache: %s", cached_obj);
        }
 
        /*
@@ -590,7 +594,6 @@ static void to_cache(ARGS *args)
                failed();
        }
 
-       cc_log("Placed object file into the cache");
        stats_tocache(file_size(&st));
 
        free(tmp_obj);
@@ -645,7 +648,7 @@ get_object_name_from_cpp(ARGS *args, struct mdfour *hash)
                path_stdout = input_file;
                if (create_empty_file(path_stderr) != 0) {
                        stats_update(STATS_ERROR);
-                       cc_log("failed to create empty stderr file");
+                       cc_log("Failed to create empty stderr file");
                        failed();
                }
                status = 0;
@@ -656,7 +659,7 @@ get_object_name_from_cpp(ARGS *args, struct mdfour *hash)
                        unlink(path_stdout);
                }
                unlink(path_stderr);
-               cc_log("the preprocessor gave %d", status);
+               cc_log("The preprocessor gave exit status %d", status);
                stats_update(STATS_PREPROCESSOR);
                failed();
        }
@@ -803,7 +806,7 @@ static int find_hash(ARGS *args, enum findhash_call_mode mode)
        /* The compiler driver size and date. This is a simple minded way
           to try and detect compiler upgrades. It is not 100% reliable. */
        if (stat(args->argv[0], &st) != 0) {
-               cc_log("Couldn't stat the compiler!? (argv[0]='%s')", args->argv[0]);
+               cc_log("Couldn't stat the compiler (%s)", args->argv[0]);
                stats_update(STATS_COMPILER);
                failed();
        }
@@ -839,13 +842,15 @@ static int find_hash(ARGS *args, enum findhash_call_mode mode)
        switch (mode) {
        case FINDHASH_DIRECT_MODE:
                if (!hash_file_ignoring_comments(&hash, input_file)) {
-                       cc_log("Failed hashing %s", input_file);
+                       cc_log("Failed to hash %s", input_file);
                        failed();
                }
                manifest_name = hash_result(&hash);
                manifest_path = get_path_in_cache(manifest_name, ".manifest",
                                                  nlevels);
                free(manifest_name);
+               cc_log("Looking for object file hash in %s",
+                      manifest_path);
                object_hash = manifest_get(manifest_path);
                if (object_hash) {
                        cc_log("Got object file hash from manifest");
@@ -928,7 +933,7 @@ static void from_cache(enum fromcache_call_mode mode, int put_object_in_manifest
                        cc_log("Object file missing for %s", output_obj);
                        stats_update(STATS_MISSING);
                } else {
-                       cc_log("Failed to copy/link %s -> %s (%s)",
+                       cc_log("Failed to copy/link %s to %s (%s)",
                               cached_obj, output_obj, strerror(errno));
                        stats_update(STATS_ERROR);
                        failed();
@@ -939,7 +944,7 @@ static void from_cache(enum fromcache_call_mode mode, int put_object_in_manifest
                unlink(cached_dep);
                return;
        } else {
-               cc_log("Created %s", output_obj);
+               cc_log("Created %s from %s", output_obj, cached_obj);
        }
 
        if (produce_dep_file) {
@@ -957,11 +962,11 @@ static void from_cache(enum fromcache_call_mode mode, int put_object_in_manifest
                                 * Someone removed the file just before we
                                 * began copying?
                                 */
-                               cc_log("dependency file missing for %s",
+                               cc_log("Dependency file missing for %s",
                                       output_obj);
                                stats_update(STATS_MISSING);
                        } else {
-                               cc_log("failed to copy/link %s -> %s (%s)",
+                               cc_log("Failed to copy/link %s to %s (%s)",
                                       cached_dep, output_dep,
                                       strerror(errno));
                                stats_update(STATS_ERROR);
@@ -974,7 +979,7 @@ static void from_cache(enum fromcache_call_mode mode, int put_object_in_manifest
                        unlink(cached_dep);
                        return;
                } else {
-                       cc_log("Created %s", output_dep);
+                       cc_log("Created %s from %s", output_dep, cached_dep);
                }
        }
 
@@ -990,11 +995,11 @@ static void from_cache(enum fromcache_call_mode mode, int put_object_in_manifest
                /* Store the dependency file in the cache. */
                ret = copy_file(output_dep, cached_dep, 1);
                if (ret == -1) {
-                       cc_log("Failed to copy %s -> %s", output_dep,
+                       cc_log("Failed to copy %s to %s", output_dep,
                               cached_dep);
                        /* Continue despite the error. */
                } else {
-                       cc_log("Placed dependency file into the cache");
+                       cc_log("Stored in cache: %s", cached_dep);
                }
        }
 
@@ -1028,7 +1033,8 @@ static void from_cache(enum fromcache_call_mode mode, int put_object_in_manifest
                                manifest_path);
                        update_mtime(manifest_path);
                } else {
-                       cc_log("Failed to add object file hash to manifest");
+                       cc_log("Failed to add object file hash to manifest %s",
+                               manifest_path);
                }
        }
 
@@ -1178,7 +1184,7 @@ static void process_args(int argc, char **argv)
                /* we need to work out where the output was meant to go */
                if (strcmp(argv[i], "-o") == 0) {
                        if (i == argc-1) {
-                               cc_log("missing argument to %s", argv[i]);
+                               cc_log("Missing argument to %s", argv[i]);
                                stats_update(STATS_ARGS);
                                failed();
                        }
@@ -1267,7 +1273,7 @@ static void process_args(int argc, char **argv)
                        for (j = 0; opts[j]; j++) {
                                if (strcmp(argv[i], opts[j]) == 0) {
                                        if (i == argc-1) {
-                                               cc_log("missing argument to %s",
+                                               cc_log("Missing argument to %s",
                                                       argv[i]);
                                                stats_update(STATS_ARGS);
                                                failed();
@@ -1319,7 +1325,7 @@ static void process_args(int argc, char **argv)
                        for (j=0;opts[j];j++) {
                                if (strcmp(argv[i], opts[j]) == 0) {
                                        if (i == argc-1) {
-                                               cc_log("missing argument to %s",
+                                               cc_log("Missing argument to %s",
                                                       argv[i]);
                                                stats_update(STATS_ARGS);
                                                failed();
@@ -1350,18 +1356,18 @@ static void process_args(int argc, char **argv)
 
                if (input_file) {
                        if (check_extension(argv[i], NULL)) {
-                               cc_log("multiple input files (%s and %s)",
+                               cc_log("Multiple input files: %s and %s",
                                       input_file, argv[i]);
                                stats_update(STATS_MULTIPLE);
                        } else if (!found_c_opt) {
-                               cc_log("called for link with %s", argv[i]);
+                               cc_log("Called for link with %s", argv[i]);
                                if (strstr(argv[i], "conftest.")) {
                                        stats_update(STATS_CONFTEST);
                                } else {
                                        stats_update(STATS_LINK);
                                }
                        } else {
-                               cc_log("non C/C++ file %s", argv[i]);
+                               cc_log("Non-C/C++ file: %s", argv[i]);
                                stats_update(STATS_NOTC);
                        }
                        failed();
@@ -1379,13 +1385,13 @@ static void process_args(int argc, char **argv)
 
        i_extension = check_extension(input_file, &direct_i_file);
        if (i_extension == NULL) {
-               cc_log("Not a C/C++ file - %s", input_file);
+               cc_log("Not a C/C++ file: %s", input_file);
                stats_update(STATS_NOTC);
                failed();
        }
 
        if (!found_c_opt) {
-               cc_log("No -c option found for %s", input_file);
+               cc_log("No -c option found");
                /* I find that having a separate statistic for autoconf tests is useful,
                   as they are the dominant form of "called for link" in many cases */
                if (strstr(input_file, "conftest.")) {
@@ -1412,7 +1418,7 @@ static void process_args(int argc, char **argv)
                }
                p = strrchr(output_obj, '.');
                if (!p || !p[1]) {
-                       cc_log("badly formed output file %s", output_obj);
+                       cc_log("Badly formed object filename");
                        stats_update(STATS_ARGS);
                        failed();
                }
@@ -1463,7 +1469,7 @@ static void process_args(int argc, char **argv)
        if (strcmp(output_obj,"/dev/null") != 0
            && stat(output_obj, &st) == 0
            && !S_ISREG(st.st_mode)) {
-               cc_log("Not a regular file %s", output_obj);
+               cc_log("Not a regular file: %s", output_obj);
                stats_update(STATS_DEVICE);
                failed();
        }
@@ -1589,7 +1595,7 @@ static void ccache(int argc, char *argv[])
        from_cache(FROMCACHE_CPP_MODE, put_object_in_manifest);
 
        if (getenv("CCACHE_READONLY")) {
-               cc_log("read-only set - doing real compile");
+               cc_log("Read-only mode; running real compiler");
                failed();
        }
 
@@ -1611,7 +1617,7 @@ static void ccache(int argc, char *argv[])
        from_cache(FROMCACHE_COMPILED_MODE, put_object_in_manifest);
 
        /* oh oh! */
-       cc_log("secondary from_cache failed!");
+       cc_log("Secondary from_cache failed");
        stats_update(STATS_ERROR);
        failed();
 }
index 960a692989a96f833cfad92ca8320ea77c794225..30355dc79b03feba3fcc9b5293dbea96d75b78c4 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -91,7 +91,7 @@ char *find_executable(const char *name, const char *exclude_name)
                path = getenv("PATH");
        }
        if (!path) {
-               cc_log("no PATH variable!?");
+               cc_log("No PATH variable");
                return NULL;
        }
 
index c18843d31044f4dfc1a87c99df1095993a9dffc0..2c66cfa97a22cac09c9a42e34c722dc5b444f824 100644 (file)
@@ -546,17 +546,17 @@ struct file_hash *manifest_get(const char *manifest_path)
                goto out;
        }
        if (read_lock_fd(fd) == -1) {
-               cc_log("Failed to read lock %s", manifest_path);
+               cc_log("Failed to read lock manifest file");
                goto out;
        }
        f = gzdopen(fd, "rb");
        if (!f) {
-               cc_log("Failed to gzdopen %s", manifest_path);
+               cc_log("Failed to gzdopen manifest file");
                goto out;
        }
        mf = read_manifest(f);
        if (!mf) {
-               cc_log("Error reading %s", manifest_path);
+               cc_log("Error reading manifest file");
                goto out;
        }
 
@@ -602,16 +602,16 @@ int manifest_put(const char *manifest_path, struct file_hash *object_hash,
 
        fd1 = safe_open(manifest_path);
        if (fd1 == -1) {
-               cc_log("Failed to open %s", manifest_path);
+               cc_log("Failed to open manifest file");
                goto out;
        }
        if (write_lock_fd(fd1) == -1) {
-               cc_log("Failed to write lock %s", manifest_path);
+               cc_log("Failed to write lock manifest file");
                close(fd1);
                goto out;
        }
        if (fstat(fd1, &st) != 0) {
-               cc_log("Failed to stat %s", manifest_path);
+               cc_log("Failed to stat manifest file");
                close(fd1);
                goto out;
        }
@@ -621,13 +621,13 @@ int manifest_put(const char *manifest_path, struct file_hash *object_hash,
        } else {
                f1 = gzdopen(fd1, "rb");
                if (!f1) {
-                       cc_log("Failed to gzdopen %s", manifest_path);
+                       cc_log("Failed to gzdopen manifest file");
                        close(fd1);
                        goto out;
                }
                mf = read_manifest(f1);
                if (!mf) {
-                       cc_log("Failed to read %s", manifest_path);
+                       cc_log("Failed to read manifest file");
                        goto out;
                }
        }
@@ -647,8 +647,8 @@ int manifest_put(const char *manifest_path, struct file_hash *object_hash,
                 * old ones. An easy way is to throw away all entries when
                 * there are too many. Let's do that for now.
                 */
-               cc_log("More than %u entries in %s; discarding",
-                       MAX_MANIFEST_ENTRIES, manifest_path);
+               cc_log("More than %u entries in manifest file; discarding",
+                       MAX_MANIFEST_ENTRIES);
                free_manifest(mf);
                mf = create_empty_manifest();
        }
@@ -675,7 +675,7 @@ int manifest_put(const char *manifest_path, struct file_hash *object_hash,
                        goto out;
                }
        } else {
-               cc_log("Failed to write manifest %s", manifest_path);
+               cc_log("Failed to write manifest file");
                goto out;
        }
 
diff --git a/stats.c b/stats.c
index 25a551f03597102e51fbe8fec8612e99a5c87646..2dd69f4f06811da7174fdfcbd9f95ca2ac51a879 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -98,10 +98,10 @@ static void write_stats(int fd, unsigned counters[STATS_END])
 
        for (i=0;i<STATS_END;i++) {
                len += snprintf(buf+len, sizeof(buf)-(len+1), "%u ", counters[i]);
-               if (len >= (int)sizeof(buf)-1) fatal("stats too long?!");
+               if (len >= (int)sizeof(buf)-1) fatal("stats too long");
        }
        len += snprintf(buf+len, sizeof(buf)-(len+1), "\n");
-       if (len >= (int)sizeof(buf)-1) fatal("stats too long?!");
+       if (len >= (int)sizeof(buf)-1) fatal("stats too long");
 
        lseek(fd, 0, SEEK_SET);
        if (write(fd, buf, len) == -1) fatal("Could not write stats");
diff --git a/util.c b/util.c
index 6d49f41824fc206093fe27af06da88bfb1c90b7b..637c228e1b5515b7c6d5bd0015758728de5c7005 100644 (file)
--- a/util.c
+++ b/util.c
@@ -345,7 +345,7 @@ char *x_strdup(const char *s)
        char *ret;
        ret = strdup(s);
        if (!ret) {
-               fatal("Out of memory in strdup");
+               fatal("Out of memory in x_strdup");
        }
        return ret;
 }
@@ -372,7 +372,7 @@ char *x_strndup(const char *s, size_t n)
        ret = strndup(s, n);
 #endif
        if (!ret) {
-               fatal("Out of memory in strndup");
+               fatal("Out of memory in x_strndup");
        }
        return ret;
 }
@@ -385,7 +385,7 @@ void *x_malloc(size_t size)
        void *ret;
        ret = malloc(size);
        if (!ret) {
-               fatal("Out of memory in malloc");
+               fatal("Out of memory in x_malloc");
        }
        return ret;
 }