mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
config: add --nofilelogging option.
This commit is contained in:
parent
1eef90fb73
commit
ebee51fbcb
19
config.go
19
config.go
@ -91,6 +91,7 @@ type config struct {
|
||||
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
|
||||
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
|
||||
LogDir string `long:"logdir" description:"Directory to log output."`
|
||||
NoFileLogging bool `long:"nofilelogging" description:"Disable file logging."`
|
||||
AddPeers []string `short:"a" long:"addpeer" description:"Add a peer to connect with at startup"`
|
||||
ConnectPeers []string `long:"connect" description:"Connect only to the specified peers at startup"`
|
||||
DisableListen bool `long:"nolisten" description:"Disable listening for incoming connections -- NOTE: Listening is automatically disabled if the --connect or --proxy options are used without also specifying listen interfaces via --listen"`
|
||||
@ -602,11 +603,17 @@ func loadConfig() (*config, []string, error) {
|
||||
var oldTestNets []string
|
||||
oldTestNets = append(oldTestNets, filepath.Join(cfg.DataDir, "testnet"))
|
||||
cfg.DataDir = filepath.Join(cfg.DataDir, netName(activeNetParams))
|
||||
logRotator = nil
|
||||
if !cfg.NoFileLogging {
|
||||
// Append the network type to the log directory so it is "namespaced"
|
||||
// per network in the same fashion as the data directory.
|
||||
cfg.LogDir = cleanAndExpandPath(cfg.LogDir)
|
||||
cfg.LogDir = filepath.Join(cfg.LogDir, netName(activeNetParams))
|
||||
|
||||
// Append the network type to the log directory so it is "namespaced"
|
||||
// per network in the same fashion as the data directory.
|
||||
cfg.LogDir = cleanAndExpandPath(cfg.LogDir)
|
||||
cfg.LogDir = filepath.Join(cfg.LogDir, netName(activeNetParams))
|
||||
// Initialize log rotation. After log rotation has been initialized, the
|
||||
// logger variables may be used.
|
||||
initLogRotator(filepath.Join(cfg.LogDir, defaultLogFilename))
|
||||
}
|
||||
|
||||
// Special show command to list supported subsystems and exit.
|
||||
if cfg.DebugLevel == "show" {
|
||||
@ -614,10 +621,6 @@ func loadConfig() (*config, []string, error) {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Initialize log rotation. After log rotation has been initialized, the
|
||||
// logger variables may be used.
|
||||
initLogRotator(filepath.Join(cfg.LogDir, defaultLogFilename))
|
||||
|
||||
// Parse, validate, and set debug log level(s).
|
||||
if err := parseAndSetDebugLevels(cfg.DebugLevel); err != nil {
|
||||
err := fmt.Errorf("%s: %v", funcName, err.Error())
|
||||
|
||||
3
dcrd.go
3
dcrd.go
@ -53,6 +53,9 @@ func dcrdMain(serverChan chan<- *server) error {
|
||||
// Show version and home dir at startup.
|
||||
dcrdLog.Infof("Version %s (Go version %s)", version(), runtime.Version())
|
||||
dcrdLog.Infof("Home dir: %s", cfg.HomeDir)
|
||||
if cfg.NoFileLogging {
|
||||
dcrdLog.Info("File logging disabled")
|
||||
}
|
||||
|
||||
// Enable http profiling server if requested.
|
||||
if cfg.Profile != "" {
|
||||
|
||||
1
doc.go
1
doc.go
@ -26,6 +26,7 @@ Application Options:
|
||||
-C, --configfile= Path to configuration file
|
||||
-b, --datadir= Directory to store data
|
||||
--logdir= Directory to log output.
|
||||
--nofilelogging= Disable file logging.
|
||||
-a, --addpeer= Add a peer to connect with at startup
|
||||
--connect= Connect only to the specified peers at startup
|
||||
--nolisten Disable listening for incoming connections -- NOTE:
|
||||
|
||||
8
log.go
8
log.go
@ -35,7 +35,9 @@ type logWriter struct{}
|
||||
|
||||
func (logWriter) Write(p []byte) (n int, err error) {
|
||||
os.Stdout.Write(p)
|
||||
logRotator.Write(p)
|
||||
if logRotator != nil {
|
||||
logRotator.Write(p)
|
||||
}
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
@ -166,6 +168,8 @@ func directionString(inbound bool) string {
|
||||
func fatalf(str string) {
|
||||
dcrdLog.Errorf("Unable to create profiler: %v", str)
|
||||
os.Stdout.Sync()
|
||||
logRotator.Close()
|
||||
if logRotator != nil {
|
||||
logRotator.Close()
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user