mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-09 01:44:17 +00:00
Remove source info in log by default
This commit is contained in:
parent
2f660aff7a
commit
7e3b29e3e0
@ -6,21 +6,16 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var debugEnabled = true
|
var logger = log.New(os.Stderr, "", log.Ltime)
|
||||||
var logger = log.New(os.Stderr, "", log.Lshortfile|log.Ltime)
|
|
||||||
|
|
||||||
func debugln(vals ...interface{}) {
|
func debugln(vals ...interface{}) {
|
||||||
if debugEnabled {
|
|
||||||
s := fmt.Sprintln(vals...)
|
s := fmt.Sprintln(vals...)
|
||||||
logger.Output(2, "DEBUG: "+s)
|
logger.Output(2, "DEBUG: "+s)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func debugf(format string, vals ...interface{}) {
|
func debugf(format string, vals ...interface{}) {
|
||||||
if debugEnabled {
|
|
||||||
s := fmt.Sprintf(format, vals...)
|
s := fmt.Sprintf(format, vals...)
|
||||||
logger.Output(2, "DEBUG: "+s)
|
logger.Output(2, "DEBUG: "+s)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func infoln(vals ...interface{}) {
|
func infoln(vals ...interface{}) {
|
||||||
|
7
main.go
7
main.go
@ -32,6 +32,7 @@ type Options struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DebugOptions struct {
|
type DebugOptions struct {
|
||||||
|
LogSource bool `long:"log-source"`
|
||||||
TraceFile bool `long:"trace-file"`
|
TraceFile bool `long:"trace-file"`
|
||||||
TraceNet bool `long:"trace-net"`
|
TraceNet bool `long:"trace-net"`
|
||||||
TraceIdx bool `long:"trace-idx"`
|
TraceIdx bool `long:"trace-idx"`
|
||||||
@ -71,13 +72,13 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Useful for debugging; to be adjusted.
|
|
||||||
log.SetFlags(log.Ltime | log.Lshortfile)
|
|
||||||
|
|
||||||
_, err := flags.Parse(&opts)
|
_, err := flags.Parse(&opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
if opts.Debug.TraceFile || opts.Debug.TraceIdx || opts.Debug.TraceNet || opts.Debug.LogSource {
|
||||||
|
logger = log.New(os.Stderr, "", log.Lshortfile|log.Ldate|log.Ltime|log.Lmicroseconds)
|
||||||
|
}
|
||||||
if strings.HasPrefix(opts.ConfDir, "~/") {
|
if strings.HasPrefix(opts.ConfDir, "~/") {
|
||||||
opts.ConfDir = strings.Replace(opts.ConfDir, "~", getHomeDir(), 1)
|
opts.ConfDir = strings.Replace(opts.ConfDir, "~", getHomeDir(), 1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user