mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 01:44:41 +01:00
Log -v output to stdout by default - fixes #228
This commit is contained in:
parent
f15e7e89d2
commit
108760e17b
@ -415,7 +415,8 @@ using `--checksum`).
|
||||
|
||||
Log all of rclone's output to FILE. This is not active by default.
|
||||
This can be useful for tracking down problems with syncs in
|
||||
combination with the `-v` flag.
|
||||
combination with the `-v` flag. See the Logging section for more
|
||||
info.
|
||||
|
||||
### --low-level-retries NUMBER ###
|
||||
|
||||
@ -705,6 +706,25 @@ For the filtering options
|
||||
|
||||
See the [filtering section](/filtering/).
|
||||
|
||||
Logging
|
||||
-------
|
||||
|
||||
rclone has 3 levels of logging, `Error`, `Info` and `Debug`.
|
||||
|
||||
By default rclone logs `Error` and `Info` to standard error and `Debug`
|
||||
to standard output. This means you can redirect standard output and
|
||||
standard error to different places.
|
||||
|
||||
By default rclone will produce `Error` and `Info` level messages.
|
||||
|
||||
If you use the `-q` flag, rclone will only produce `Error` messages.
|
||||
|
||||
If you use the `-v` flag, rclone will produce `Error`, `Info` and
|
||||
`Debug` messages.
|
||||
|
||||
If you use the `--log-file=FILE` option, rclone will redirect `Error`,
|
||||
`Info` and `Debug` messages along with standard error to FILE.
|
||||
|
||||
Exit Code
|
||||
---------
|
||||
|
||||
|
28
fs/fs.go
28
fs/fs.go
@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
@ -357,27 +358,30 @@ func NewFs(path string) (Fs, error) {
|
||||
return fs.NewFs(configName, fsPath)
|
||||
}
|
||||
|
||||
// OutputLog logs for an object
|
||||
func OutputLog(o interface{}, text string, args ...interface{}) {
|
||||
description := ""
|
||||
if o != nil {
|
||||
description = fmt.Sprintf("%v: ", o)
|
||||
}
|
||||
// DebugLogger - logs to Stdout
|
||||
var DebugLogger = log.New(os.Stdout, "", log.LstdFlags)
|
||||
|
||||
// makeLog produces a log string from the arguments passed in
|
||||
func makeLog(o interface{}, text string, args ...interface{}) string {
|
||||
out := fmt.Sprintf(text, args...)
|
||||
log.Print(description + out)
|
||||
if o == nil {
|
||||
return out
|
||||
}
|
||||
return fmt.Sprintf("%v: %s", o, out)
|
||||
}
|
||||
|
||||
// Debug writes debuging output for this Object or Fs
|
||||
// Debug writes debugging output for this Object or Fs
|
||||
func Debug(o interface{}, text string, args ...interface{}) {
|
||||
if Config.Verbose {
|
||||
OutputLog(o, text, args...)
|
||||
DebugLogger.Print(makeLog(o, text, args...))
|
||||
}
|
||||
}
|
||||
|
||||
// Log writes log output for this Object or Fs
|
||||
// Log writes log output for this Object or Fs. This should be
|
||||
// considered to be Info level logging.
|
||||
func Log(o interface{}, text string, args ...interface{}) {
|
||||
if !Config.Quiet {
|
||||
OutputLog(o, text, args...)
|
||||
log.Print(makeLog(o, text, args...))
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,7 +389,7 @@ func Log(o interface{}, text string, args ...interface{}) {
|
||||
// unconditionally logs a message regardless of Config.Quiet or
|
||||
// Config.Verbose.
|
||||
func ErrorLog(o interface{}, text string, args ...interface{}) {
|
||||
OutputLog(o, text, args...)
|
||||
log.Print(makeLog(o, text, args...))
|
||||
}
|
||||
|
||||
// CheckClose is a utility function used to check the return from
|
||||
|
Loading…
Reference in New Issue
Block a user