fs/accounting: add --stats-one-line flag for single line stats
This commit is contained in:
parent
80a3db34a8
commit
6390dec7db
4 changed files with 36 additions and 22 deletions
|
@ -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
|
you want them to then use `--stats-log-level NOTICE`. See the [Logging
|
||||||
section](#logging) for more info on log levels.
|
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 ###
|
### --stats-unit=bits|bytes ###
|
||||||
|
|
||||||
By default, data transfer rates will be printed in bytes/second.
|
By default, data transfer rates will be printed in bytes/second.
|
||||||
|
|
|
@ -173,41 +173,48 @@ func (s *StatsInfo) String() string {
|
||||||
if eta > 0 {
|
if eta > 0 {
|
||||||
etaString = eta.String()
|
etaString = eta.String()
|
||||||
}
|
}
|
||||||
xfrchk := []string{}
|
if !fs.Config.StatsOneLine {
|
||||||
if totalTransfer > 0 && s.transferQueue > 0 {
|
_, _ = fmt.Fprintf(buf, "\nTransferred: ")
|
||||||
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))
|
|
||||||
}
|
}
|
||||||
xfrchkString := ""
|
xfrchkString := ""
|
||||||
if len(xfrchk) > 0 {
|
if fs.Config.StatsOneLine {
|
||||||
xfrchkString = fmt.Sprintf(" (%s)", strings.Join(xfrchk, ", "))
|
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, "%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)
|
||||||
_, _ = fmt.Fprintf(buf, `
|
if !fs.Config.StatsOneLine {
|
||||||
Transferred: %10s / %s, %d%%, %s, ETA %s%s
|
_, _ = fmt.Fprintf(buf, `
|
||||||
Errors: %10d
|
Errors: %10d
|
||||||
Checks: %10d / %d, %d%%
|
Checks: %10d / %d, %d%%
|
||||||
Transferred: %10d / %d, %d%%
|
Transferred: %10d / %d, %d%%
|
||||||
Elapsed time: %10v
|
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.errors,
|
s.checks, totalChecks, percent(s.checks, totalChecks),
|
||||||
s.checks, totalChecks, percent(s.checks, totalChecks),
|
s.transfers, totalTransfer, percent(s.transfers, totalTransfer),
|
||||||
s.transfers, totalTransfer, percent(s.transfers, totalTransfer),
|
dtRounded)
|
||||||
dtRounded)
|
}
|
||||||
|
|
||||||
// checking and transferring have their own locking so unlock
|
// checking and transferring have their own locking so unlock
|
||||||
// here to prevent deadlock on GetBytes
|
// here to prevent deadlock on GetBytes
|
||||||
s.mu.RUnlock()
|
s.mu.RUnlock()
|
||||||
|
|
||||||
if !s.checking.empty() {
|
if !fs.Config.StatsOneLine {
|
||||||
_, _ = fmt.Fprintf(buf, "Checking:\n%s\n", s.checking)
|
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 !s.transferring.empty() {
|
||||||
|
_, _ = fmt.Fprintf(buf, "Transferring:\n%s\n", s.transferring)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ type ConfigInfo struct {
|
||||||
UseServerModTime bool
|
UseServerModTime bool
|
||||||
MaxTransfer SizeSuffix
|
MaxTransfer SizeSuffix
|
||||||
MaxBacklog int
|
MaxBacklog int
|
||||||
|
StatsOneLine bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfig creates a new config with everything set to the default
|
// NewConfig creates a new config with everything set to the default
|
||||||
|
|
|
@ -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.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.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.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
|
// SetFlags converts any flags into config which weren't straight foward
|
||||||
|
|
Loading…
Reference in a new issue