X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/11a5a3c704fd75325450ddae3fb2cb01f19b7111..74e708d85a5589ab973e2db6cf2ce20204fc82a4:/log.c diff --git a/log.c b/log.c index a5867932..21b5c1c2 100644 --- 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); } +