hanle null strings in -vvv output
[rsync/rsync.git] / log.c
diff --git a/log.c b/log.c
index a586793..21b5c1c 100644 (file)
--- a/log.c
+++ b/log.c
@@ -51,7 +51,8 @@ static char *timestring(void )
 static void logit(int priority, char *buf)
 {
        if (logfile) {
-               fprintf(logfile,"%s  %s", timestring(), buf);
+               fprintf(logfile,"%s [%d] %s", 
+                       timestring(), (int)getpid(), buf);
                fflush(logfile);
        } else {
                syslog(priority, "%s", buf);
@@ -63,12 +64,14 @@ void log_open(void)
        static int initialised;
        int options = LOG_PID;
        time_t t;
+       char *logf;
 
        if (initialised) return;
        initialised = 1;
 
-       if (lp_log_file()) {
-               logfile = fopen(lp_log_file(), "a");
+       logf = lp_log_file();
+       if (logf && *logf) {
+               logfile = fopen(logf, "a");
                return;
        }
 
@@ -207,6 +210,20 @@ void log_recv(struct file_struct *file)
        }
 }
 
+/* called when the transfer is interrupted for some reason */
+void log_exit(int code)
+{
+       if (code == 0) {
+               extern struct stats stats;              
+               rprintf(FLOG,"wrote %.0f bytes  read %.0f bytes  total size %.0f\n",
+                       (double)stats.total_written,
+                       (double)stats.total_read,
+                       (double)stats.total_size);
+       } else {
+               rprintf(FLOG,"transfer interrupted\n");
+       }
+}
+
 /* log the incoming transfer of a file for interactive use, this
    will be called at the end where the client was run */
 void log_transfer(struct file_struct *file, char *fname)
@@ -217,3 +234,4 @@ void log_transfer(struct file_struct *file, char *fname)
 
        rprintf(FINFO,"%s\n", fname);
 }
+