From dd856160aa0ddef35dff1db802556d3600c77792 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Wed, 30 Jul 2014 12:17:19 -0500 Subject: [PATCH] Save logs to network specific directories. Fixes #114. --- config.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config.go b/config.go index 2f6654a..6bc1fad 100644 --- a/config.go +++ b/config.go @@ -313,12 +313,15 @@ func loadConfig() (*config, []string, error) { } } + // Choose the active network params based on the selected network. // Multiple networks can't be selected simultaneously. numNets := 0 if cfg.MainNet { + activeNet = &mainNetParams numNets++ } if cfg.SimNet { + activeNet = &simNetParams numNets++ } if numNets > 1 { @@ -330,13 +333,10 @@ func loadConfig() (*config, []string, error) { return nil, nil, err } - // Choose the active network params based on the selected network. - switch { - case cfg.MainNet: - activeNet = &mainNetParams - case cfg.SimNet: - activeNet = &simNetParams - } + // Append the network type to the log directory so it is "namespaced" + // per network. + cfg.LogDir = cleanAndExpandPath(cfg.LogDir) + cfg.LogDir = filepath.Join(cfg.LogDir, activeNet.Params.Name) // Special show command to list supported subsystems and exit. if cfg.DebugLevel == "show" {