- char *s_or_r = am_sender ? "send" : "recv";
-
- if (lp_transfer_logging(module_id)) {
- log_formatted(FLOG, lp_log_format(module_id), s_or_r,
- file, initial_stats, iflags, hlink);
- } else if (log_format && !am_server) {
- log_formatted(FINFO, log_format, s_or_r,
- file, initial_stats, iflags, hlink);
+ const char *p;
+
+ if (!format)
+ return 0;
+
+ for (p = format; (p = strchr(p, '%')) != NULL; ) {
+ if (*++p == '-')
+ p++;
+ while (isDigit(p))
+ p++;
+ if (!*p)
+ break;
+ if (*p == esc)
+ return 1;
+ }
+ return 0;
+}
+
+/* Log the transfer of a file. If the code is FCLIENT, the output just goes
+ * to stdout. If it is FLOG, it just goes to the log file. Otherwise we
+ * output to both. */
+void log_item(enum logcode code, struct file_struct *file,
+ struct stats *initial_stats, int iflags, const char *hlink)
+{
+ const char *s_or_r = am_sender ? "send" : "recv";
+
+ if (code != FLOG && stdout_format && !am_server) {
+ log_formatted(FCLIENT, stdout_format, s_or_r,
+ file, NULL, initial_stats, iflags, hlink);
+ }
+ if (code != FCLIENT && logfile_format && *logfile_format) {
+ log_formatted(FLOG, logfile_format, s_or_r,
+ file, NULL, initial_stats, iflags, hlink);
+ }
+}
+
+void maybe_log_item(struct file_struct *file, int iflags, int itemizing,
+ const char *buf)
+{
+ int significant_flags = iflags & SIGNIFICANT_ITEM_FLAGS;
+ int see_item = itemizing && (significant_flags || *buf
+ || stdout_format_has_i > 1 || (INFO_GTE(NAME, 2) && stdout_format_has_i));
+ int local_change = iflags & ITEM_LOCAL_CHANGE && significant_flags;
+ if (am_server) {
+ if (logfile_name && !dry_run && see_item
+ && (significant_flags || logfile_format_has_i))
+ log_item(FLOG, file, &stats, iflags, buf);
+ } else if (see_item || local_change || *buf
+ || (S_ISDIR(file->mode) && significant_flags)) {
+ enum logcode code = significant_flags || logfile_format_has_i ? FINFO : FCLIENT;
+ log_item(code, file, &stats, iflags, buf);