]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Show hostname and CWD in logfile
authorWilson Snyder <wsnyder@wsnyder.org>
Sun, 9 May 2010 11:12:32 +0000 (13:12 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 9 May 2010 11:18:38 +0000 (13:18 +0200)
ccache.c
ccache.h
util.c

index de08a5c8e53b415d0f658b26415a70b753505198..b2a55c2ec9a53937402da899035a5ca260f0e97f 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1674,6 +1674,10 @@ static void ccache(int argc, char *argv[])
        process_args(orig_args->argc, orig_args->argv, &preprocessor_args,
                     &compiler_args);
 
+       cc_log("Hostname: %s", get_hostname());
+
+       cc_log("Cwd: %s", current_working_dir);
+
        cc_log("Source file: %s", input_file);
        if (generating_dependencies) {
                cc_log("Dependency file: %s", output_dep);
index f514057d24240adbd44be1560097a28b98a9fa12..227734410310dcc84e7817d59b87b96fa428243c 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -73,6 +73,7 @@ int move_file(const char *src, const char *dest, int compress_dest);
 int test_if_compressed(const char *filename);
 
 int create_dir(const char *dir);
+const char *get_hostname(void);
 const char *tmp_string(void);
 char *format_hash_as_string(const unsigned char *hash, unsigned size);
 int create_hash_dir(char **dir, const char *hash, const char *cache_dir);
diff --git a/util.c b/util.c
index 34f1b5e65b51233738e721c8480a4c3caa773e1e..e10e1ca9c2b894e7563b891a58911bb251f4d9c5 100644 (file)
--- a/util.c
+++ b/util.c
@@ -272,21 +272,33 @@ int create_dir(const char *dir)
 }
 
 /*
- * Return a string to be used to distinguish temporary files. Also tries to
- * cope with NFS by adding the local hostname.
+ * Return a static string with the current hostname.
  */
-const char *tmp_string(void)
+const char *get_hostname(void)
 {
-       static char *ret;
+       static char hostname[200] = "";
 
-       if (!ret) {
-               char hostname[200];
+       if (!hostname[0]) {
                strcpy(hostname, "unknown");
 #if HAVE_GETHOSTNAME
                gethostname(hostname, sizeof(hostname)-1);
 #endif
                hostname[sizeof(hostname)-1] = 0;
-               x_asprintf(&ret, "%s.%u", hostname, (unsigned)getpid());
+       }
+
+       return hostname;
+}
+
+/*
+ * Return a string to be used to distinguish temporary files. Also tries to
+ * cope with NFS by adding the local hostname.
+ */
+const char *tmp_string(void)
+{
+       static char *ret;
+
+       if (!ret) {
+               x_asprintf(&ret, "%s.%u", get_hostname(), (unsigned)getpid());
        }
 
        return ret;