Reduce default verbosity now that the GUI is there

This commit is contained in:
Jakob Borg 2014-02-03 16:01:17 +01:00
parent a1d575894a
commit 89c2f61b30
2 changed files with 29 additions and 27 deletions

File diff suppressed because one or more lines are too long

54
main.go
View File

@ -33,10 +33,10 @@ var (
var ( var (
showVersion bool showVersion bool
showConfig bool
confDir string confDir string
trace string trace string
profiler string profiler string
verbose bool
) )
func main() { func main() {
@ -44,10 +44,10 @@ func main() {
logger = log.New(os.Stderr, "", log.Flags()) logger = log.New(os.Stderr, "", log.Flags())
flag.StringVar(&confDir, "home", "~/.syncthing", "Set configuration directory") flag.StringVar(&confDir, "home", "~/.syncthing", "Set configuration directory")
flag.BoolVar(&showConfig, "config", false, "Print current configuration")
flag.StringVar(&trace, "debug.trace", "", "(connect,net,idx,file,pull)") flag.StringVar(&trace, "debug.trace", "", "(connect,net,idx,file,pull)")
flag.StringVar(&profiler, "debug.profiler", "", "(addr)") flag.StringVar(&profiler, "debug.profiler", "", "(addr)")
flag.BoolVar(&showVersion, "version", false, "Show version") flag.BoolVar(&showVersion, "version", false, "Show version")
flag.BoolVar(&verbose, "v", false, "Be more verbose")
flag.Usage = usageFor(flag.CommandLine, "syncthing [options]") flag.Usage = usageFor(flag.CommandLine, "syncthing [options]")
flag.Parse() flag.Parse()
@ -84,6 +84,9 @@ func main() {
log.SetPrefix("[" + myID[0:5] + "] ") log.SetPrefix("[" + myID[0:5] + "] ")
logger.SetPrefix("[" + myID[0:5] + "] ") logger.SetPrefix("[" + myID[0:5] + "] ")
infoln("Version", Version)
infoln("My ID:", myID)
// Prepare to be able to save configuration // Prepare to be able to save configuration
cfgFile := path.Join(confDir, "config.xml") cfgFile := path.Join(confDir, "config.xml")
@ -144,18 +147,7 @@ func main() {
infof("Edit %s to taste or use the GUI\n", cfgFile) infof("Edit %s to taste or use the GUI\n", cfgFile)
} }
if showConfig {
writeConfigXML(os.Stdout, cfg)
os.Exit(0)
}
infoln("Version", Version)
infoln("My ID:", myID)
var dir = expandTilde(cfg.Repositories[0].Directory) var dir = expandTilde(cfg.Repositories[0].Directory)
if len(dir) == 0 {
fatalln("No repository directory. Set dir under [repository] in syncthing.ini.")
}
if len(profiler) > 0 { if len(profiler) > 0 {
go func() { go func() {
@ -206,29 +198,37 @@ func main() {
// Walk the repository and update the local model before establishing any // Walk the repository and update the local model before establishing any
// connections to other nodes. // connections to other nodes.
infoln("Populating repository index") if verbose {
infoln("Populating repository index")
}
loadIndex(m) loadIndex(m)
updateLocalModel(m) updateLocalModel(m)
// Routine to listen for incoming connections // Routine to listen for incoming connections
infoln("Listening for incoming connections") if verbose {
infoln("Listening for incoming connections")
}
go listen(myID, cfg.Options.ListenAddress, m, tlsCfg) go listen(myID, cfg.Options.ListenAddress, m, tlsCfg)
// Routine to connect out to configured nodes // Routine to connect out to configured nodes
infoln("Attempting to connect to other nodes") if verbose {
infoln("Attempting to connect to other nodes")
}
go connect(myID, cfg.Options.ListenAddress, m, tlsCfg) go connect(myID, cfg.Options.ListenAddress, m, tlsCfg)
// Routine to pull blocks from other nodes to synchronize the local // Routine to pull blocks from other nodes to synchronize the local
// repository. Does not run when we are in read only (publish only) mode. // repository. Does not run when we are in read only (publish only) mode.
if !cfg.Options.ReadOnly { if !cfg.Options.ReadOnly {
if cfg.Options.AllowDelete { if verbose {
infoln("Deletes from peer nodes are allowed") if cfg.Options.AllowDelete {
} else { infoln("Deletes from peer nodes are allowed")
infoln("Deletes from peer nodes will be ignored") } else {
infoln("Deletes from peer nodes will be ignored")
}
okln("Ready to synchronize (read-write)")
} }
okln("Ready to synchronize (read-write)")
m.StartRW(cfg.Options.AllowDelete, cfg.Options.ParallelRequests) m.StartRW(cfg.Options.AllowDelete, cfg.Options.ParallelRequests)
} else { } else if verbose {
okln("Ready to synchronize (read only; no external updates accepted)") okln("Ready to synchronize (read only; no external updates accepted)")
} }
@ -244,8 +244,10 @@ func main() {
} }
}() }()
// Periodically print statistics if verbose {
go printStatsLoop(m) // Periodically print statistics
go printStatsLoop(m)
}
select {} select {}
} }
@ -374,13 +376,13 @@ func connect(myID string, addr string, m *model.Model, tlsCfg *tls.Config) {
if !cfg.Options.LocalAnnEnabled { if !cfg.Options.LocalAnnEnabled {
port = -1 port = -1
} else { } else if verbose {
infoln("Sending local discovery announcements") infoln("Sending local discovery announcements")
} }
if !cfg.Options.GlobalAnnEnabled { if !cfg.Options.GlobalAnnEnabled {
cfg.Options.GlobalAnnServer = "" cfg.Options.GlobalAnnServer = ""
} else { } else if verbose {
infoln("Sending external discovery announcements") infoln("Sending external discovery announcements")
} }