diff --git a/docs/content/docs.md b/docs/content/docs.md index 4df0df26b..187cd4cb4 100644 --- a/docs/content/docs.md +++ b/docs/content/docs.md @@ -681,6 +681,11 @@ default level of logging which is `NOTICE` the stats won't show - if you want them to then use `--stats-log-level NOTICE`. See the [Logging section](#logging) for more info on log levels. +### --stats-one-line ### + +When this is specified, rclone condenses the stats into a single line +showing the most important stats only. + ### --stats-unit=bits|bytes ### By default, data transfer rates will be printed in bytes/second. diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go index 9c5c90063..1e795fd45 100644 --- a/fs/accounting/stats.go +++ b/fs/accounting/stats.go @@ -173,41 +173,48 @@ func (s *StatsInfo) String() string { if eta > 0 { etaString = eta.String() } - xfrchk := []string{} - if totalTransfer > 0 && s.transferQueue > 0 { - xfrchk = append(xfrchk, fmt.Sprintf("xfr#%d/%d", s.transfers, totalTransfer)) - } - if totalChecks > 0 && s.checkQueue > 0 { - xfrchk = append(xfrchk, fmt.Sprintf("chk#%d/%d", s.checks, totalChecks)) + if !fs.Config.StatsOneLine { + _, _ = fmt.Fprintf(buf, "\nTransferred: ") } xfrchkString := "" - if len(xfrchk) > 0 { - xfrchkString = fmt.Sprintf(" (%s)", strings.Join(xfrchk, ", ")) + if fs.Config.StatsOneLine { + xfrchk := []string{} + if totalTransfer > 0 && s.transferQueue > 0 { + xfrchk = append(xfrchk, fmt.Sprintf("xfr#%d/%d", s.transfers, totalTransfer)) + } + if totalChecks > 0 && s.checkQueue > 0 { + xfrchk = append(xfrchk, fmt.Sprintf("chk#%d/%d", s.checks, totalChecks)) + } + if len(xfrchk) > 0 { + xfrchkString = fmt.Sprintf(" (%s)", strings.Join(xfrchk, ", ")) + } } - // FIXME make a one line display too - - _, _ = fmt.Fprintf(buf, ` -Transferred: %10s / %s, %d%%, %s, ETA %s%s + _, _ = fmt.Fprintf(buf, "%10s / %s, %d%%, %s, ETA %s%s", + fs.SizeSuffix(s.bytes), fs.SizeSuffix(totalSize).Unit("Bytes"), percent(s.bytes, totalSize), fs.SizeSuffix(speed).Unit(strings.Title(fs.Config.DataRateUnit)+"/s"), etaString, xfrchkString) + if !fs.Config.StatsOneLine { + _, _ = fmt.Fprintf(buf, ` Errors: %10d Checks: %10d / %d, %d%% Transferred: %10d / %d, %d%% Elapsed time: %10v `, - fs.SizeSuffix(s.bytes), fs.SizeSuffix(totalSize).Unit("Bytes"), percent(s.bytes, totalSize), fs.SizeSuffix(speed).Unit(strings.Title(fs.Config.DataRateUnit)+"/s"), etaString, xfrchkString, - s.errors, - s.checks, totalChecks, percent(s.checks, totalChecks), - s.transfers, totalTransfer, percent(s.transfers, totalTransfer), - dtRounded) + s.errors, + s.checks, totalChecks, percent(s.checks, totalChecks), + s.transfers, totalTransfer, percent(s.transfers, totalTransfer), + dtRounded) + } // checking and transferring have their own locking so unlock // here to prevent deadlock on GetBytes s.mu.RUnlock() - if !s.checking.empty() { - _, _ = fmt.Fprintf(buf, "Checking:\n%s\n", s.checking) - } - if !s.transferring.empty() { - _, _ = fmt.Fprintf(buf, "Transferring:\n%s\n", s.transferring) + if !fs.Config.StatsOneLine { + if !s.checking.empty() { + _, _ = fmt.Fprintf(buf, "Checking:\n%s\n", s.checking) + } + if !s.transferring.empty() { + _, _ = fmt.Fprintf(buf, "Transferring:\n%s\n", s.transferring) + } } return buf.String() } diff --git a/fs/config.go b/fs/config.go index 7d5640ac1..6ffd8f1a5 100644 --- a/fs/config.go +++ b/fs/config.go @@ -82,6 +82,7 @@ type ConfigInfo struct { UseServerModTime bool MaxTransfer SizeSuffix MaxBacklog int + StatsOneLine bool } // NewConfig creates a new config with everything set to the default diff --git a/fs/config/configflags/configflags.go b/fs/config/configflags/configflags.go index 3b99ed885..749120d51 100644 --- a/fs/config/configflags/configflags.go +++ b/fs/config/configflags/configflags.go @@ -84,6 +84,7 @@ func AddFlags(flagSet *pflag.FlagSet) { flags.FVarP(flagSet, &fs.Config.Dump, "dump", "", "List of items to dump from: "+fs.DumpFlagsList) flags.FVarP(flagSet, &fs.Config.MaxTransfer, "max-transfer", "", "Maximum size of data to transfer.") flags.IntVarP(flagSet, &fs.Config.MaxBacklog, "max-backlog", "", fs.Config.MaxBacklog, "Maximum number of objects in sync or check backlog.") + flags.BoolVarP(flagSet, &fs.Config.StatsOneLine, "stats-one-line", "", fs.Config.StatsOneLine, "Make the stats fit on one line.") } // SetFlags converts any flags into config which weren't straight foward