Update core. Refactor error logging code.

This commit is contained in:
Kleissner
2022-01-12 22:34:21 +01:00
parent 5260dc354e
commit 1a8f4cc7d6
5 changed files with 10 additions and 29 deletions

View File

@@ -264,7 +264,7 @@ func userCommands(backend *core.Backend, input io.Reader, output io.Writer, term
case "log error":
fmt.Fprintf(output, "Please choose the target output of error messages:\n0 = Log file (default)\n1 = Command line\n2 = Log file + command line\n3 = None\n")
if number, valid, terminate := getUserOptionInt(reader, terminateSignal); valid && number >= 0 && number <= 3 {
config.ErrorOutput = number
backend.Config.LogTarget = number
} else if terminate {
return
} else {
@@ -444,7 +444,7 @@ func userCommands(backend *core.Backend, input io.Reader, output io.Writer, term
go blockTransfer(peer, uint64(blockNumber), output)
case "exit":
backend.Filters.LogError("userCommands", "graceful exit via user terminal command\n")
backend.LogError("userCommands", "graceful exit via user terminal command\n")
os.Exit(core.ExitGraceful)
case "search file":
@@ -642,21 +642,6 @@ func GetPeerlistSorted(backend *core.Backend) (peers []*core.PeerInfo) {
return peers
}
// logError handles error messages from core
func logError(function, format string, v ...interface{}) {
switch config.ErrorOutput {
case 0:
core.DefaultLogError(function, format, v...)
case 1:
fmt.Printf("["+function+"] "+format, v...)
case 2:
core.DefaultLogError(function, format, v...)
fmt.Printf("["+function+"] "+format, v...)
}
}
// ---- command-line helper functions ----
// timeRetryUserInput defines how long the code waits for user input from reader before trying again