per-file logging of interactive rsync sessions.
/* a generic logging routine for send/recv, with parameter
substitiution */
-static void log_formatted(char *op, struct file_struct *file,
+static void log_formatted(int fd,
+ char *format, char *op, struct file_struct *file,
struct stats *initial_stats)
{
extern int module_id;
extern int am_sender;
int64 b;
- strlcpy(buf, lp_log_format(module_id), sizeof(buf)-1);
+ strlcpy(buf, format, sizeof(buf)-1);
for (s=&buf[0];
s && (p=strchr(s,'%')); ) {
f_name(file));
clean_fname(buf2);
n = buf2;
+ if (*n == '/') n++;
break;
case 'm': n = lp_name(module_id); break;
+ case 't': n = timestring(time(NULL)); break;
case 'P': n = lp_path(module_id); break;
case 'u': n = auth_user; break;
case 'b':
s = p+l;
}
- rprintf(FLOG,"%s\n", buf);
+ rprintf(fd,"%s\n", buf);
}
/* log the outgoing transfer of a file */
void log_send(struct file_struct *file, struct stats *initial_stats)
{
extern int module_id;
+ extern int am_server;
+ extern char *log_format;
+
if (lp_transfer_logging(module_id)) {
- log_formatted("send", file, initial_stats);
+ log_formatted(FLOG, lp_log_format(module_id), "send", file, initial_stats);
+ } else if (log_format && !am_server) {
+ log_formatted(FINFO, log_format, "send", file, initial_stats);
}
}
void log_recv(struct file_struct *file, struct stats *initial_stats)
{
extern int module_id;
+ extern int am_server;
+ extern char *log_format;
+
if (lp_transfer_logging(module_id)) {
- log_formatted("recv", file, initial_stats);
+ log_formatted(FLOG, lp_log_format(module_id), "send", file, initial_stats);
+ } else if (log_format && !am_server) {
+ log_formatted(FINFO, log_format, "send", file, initial_stats);
}
}
}
/* log the incoming transfer of a file for interactive use, this
- will be called at the end where the client was run */
+ will be called at the end where the client was run
+
+ it i called when a file starts to be transferred
+*/
void log_transfer(struct file_struct *file, char *fname)
{
extern int verbose;
char *compare_dest = NULL;
char *config_file = RSYNCD_CONF;
char *shell_cmd = NULL;
+char *log_format = NULL;
char *rsync_path = RSYNC_NAME;
int rsync_port = RSYNC_PORT;
rprintf(F," --port=PORT specify alternate rsyncd port number\n");
rprintf(F," --stats give some file transfer stats\n");
rprintf(F," --progress show progress during transfer\n");
+ rprintf(F," --log-format=FORMAT log file transfers using specified format\n");
rprintf(F," -h, --help show this help screen\n");
rprintf(F,"\n");
OPT_EXCLUDE_FROM,OPT_DELETE,OPT_NUMERIC_IDS,OPT_RSYNC_PATH,
OPT_FORCE,OPT_TIMEOUT,OPT_DAEMON,OPT_CONFIG,OPT_PORT,
OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_STATS, OPT_PARTIAL, OPT_PROGRESS,
- OPT_SAFE_LINKS, OPT_COMPARE_DEST};
+ OPT_SAFE_LINKS, OPT_COMPARE_DEST, OPT_LOG_FORMAT};
static char *short_options = "oblLWHpguDCtcahvrRIxnSe:B:T:z";
{"partial", 0, 0, OPT_PARTIAL},
{"config", 1, 0, OPT_CONFIG},
{"port", 1, 0, OPT_PORT},
+ {"log-format", 1, 0, OPT_LOG_FORMAT},
{0,0,0,0}};
rsync_port = atoi(optarg);
break;
+ case OPT_LOG_FORMAT:
+ log_format = optarg;
+ break;
+
default:
return 0;
}
--port=PORT specify alternate rsyncd port number
--stats give some file transfer stats
--progress show progress during transfer
+ --log-format=FORMAT log file transfers using specified format
-h, --help show this help screen
)
dit(bf(--port PORT)) This specifies an alternate TCP port number to use
rather than the default port 873.
+dit(bf(--log-format=FORMAT)) Normally rsync just logs filenames as
+they are transferred. This allows you to specify exactly what gets
+logged on a per file basis. The log format is specified using the same
+format conventions as the log format option in rsyncd.conf.
+
dit(bf(--stats)) This tells rsync to print a verbose set of statistics
on the file transfer, allowing you to tell how effective the rsync
algorithm is for your data. This option only works in conjunction with
it() %f for the filename
it() %P for the module path
it() %m for the module name
+ it() %t for the current time
it() %u for the authenticated username (or the null string)
it() %b for the number of bytes actually transferred
it() %c when sending files this gives the number of checksum bytes