mirror of
https://github.com/rclone/rclone.git
synced 2025-01-22 22:28:47 +01:00
fs: expand stats output for json log
This commit is contained in:
parent
6893ce0bbf
commit
12a208a880
@ -375,7 +375,13 @@ func (s *StatsInfo) Transferred() []TransferSnapshot {
|
|||||||
|
|
||||||
// Log outputs the StatsInfo to the log
|
// Log outputs the StatsInfo to the log
|
||||||
func (s *StatsInfo) Log() {
|
func (s *StatsInfo) Log() {
|
||||||
|
if fs.Config.UseJSONLog {
|
||||||
|
out, _ := s.RemoteStats()
|
||||||
|
fs.LogLevelPrintf(fs.Config.StatsLogLevel, nil, "%T\n", map[string]interface{}(out))
|
||||||
|
} else {
|
||||||
fs.LogLevelPrintf(fs.Config.StatsLogLevel, nil, "%v\n", s)
|
fs.LogLevelPrintf(fs.Config.StatsLogLevel, nil, "%v\n", s)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bytes updates the stats for bytes bytes
|
// Bytes updates the stats for bytes bytes
|
||||||
|
@ -3,6 +3,7 @@ package fs
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -86,6 +87,10 @@ func LogPrintf(level LogLevel, o interface{}, text string, args ...interface{})
|
|||||||
"objectType": fmt.Sprintf("%T", o),
|
"objectType": fmt.Sprintf("%T", o),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(out, "map[") {
|
||||||
|
fields["json"] = args[0]
|
||||||
|
out = ""
|
||||||
|
}
|
||||||
switch level {
|
switch level {
|
||||||
case LogLevelDebug:
|
case LogLevelDebug:
|
||||||
logrus.WithFields(fields).Debug(out)
|
logrus.WithFields(fields).Debug(out)
|
||||||
|
Loading…
Reference in New Issue
Block a user