|
|
|
@ -30,7 +30,6 @@ import ( |
|
|
|
|
"github.com/harmony-one/harmony/node" |
|
|
|
|
"github.com/harmony-one/harmony/p2p" |
|
|
|
|
"github.com/harmony-one/harmony/p2p/p2pimpl" |
|
|
|
|
"github.com/natefinch/lumberjack" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
@ -62,24 +61,6 @@ func printVersion() { |
|
|
|
|
os.Exit(0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func initLogFile(logFolder, role, ip, port string, onlyLogTps bool, logMaxSize int) { |
|
|
|
|
// Setup a logger to stdout and log file.
|
|
|
|
|
if err := os.MkdirAll(logFolder, 0755); err != nil { |
|
|
|
|
panic(err) |
|
|
|
|
} |
|
|
|
|
utils.AddLogHandler( |
|
|
|
|
log.StreamHandler(&lumberjack.Logger{ |
|
|
|
|
Filename: fmt.Sprintf("./%v/%s-%v-%v.log", logFolder, role, ip, port), |
|
|
|
|
MaxSize: logMaxSize, |
|
|
|
|
Compress: true, |
|
|
|
|
}, log.JSONFormat())) |
|
|
|
|
|
|
|
|
|
if onlyLogTps { |
|
|
|
|
matchFilterHandler := log.MatchFilterHandler("msg", "TPS Report", utils.GetLogInstance().GetHandler()) |
|
|
|
|
utils.GetLogInstance().SetHandler(matchFilterHandler) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
ip = flag.String("ip", "127.0.0.1", "ip of the node") |
|
|
|
|
port = flag.String("port", "9000", "port of the node.") |
|
|
|
@ -157,10 +138,6 @@ func initSetup() { |
|
|
|
|
// Setup mem profiling.
|
|
|
|
|
memprofiling.GetMemProfiling().Config() |
|
|
|
|
|
|
|
|
|
// Logging setup
|
|
|
|
|
utils.SetLogContext(*port, *ip) |
|
|
|
|
utils.SetLogVerbosity(log.Lvl(*verbosity)) |
|
|
|
|
|
|
|
|
|
// Set default keystore Dir
|
|
|
|
|
hmykey.DefaultKeyStoreDir = *keystoreDir |
|
|
|
|
|
|
|
|
@ -459,13 +436,20 @@ func main() { |
|
|
|
|
} |
|
|
|
|
blsPassphrase = passphrase |
|
|
|
|
|
|
|
|
|
// Configure log parameters
|
|
|
|
|
utils.SetLogContext(*port, *ip) |
|
|
|
|
utils.SetLogVerbosity(log.Lvl(*verbosity)) |
|
|
|
|
|
|
|
|
|
initSetup() |
|
|
|
|
nodeConfig := createGlobalConfig() |
|
|
|
|
initLogFile(*logFolder, nodeConfig.StringRole, *ip, *port, *onlyLogTps, *logMaxSize) |
|
|
|
|
|
|
|
|
|
// Logging setup
|
|
|
|
|
utils.SetLogContext(*port, *ip) |
|
|
|
|
utils.SetLogVerbosity(log.Lvl(*verbosity)) |
|
|
|
|
filename := fmt.Sprintf("%v/%s-%v-%v.log", *logFolder, nodeConfig.StringRole, *ip, *port) |
|
|
|
|
if err := utils.AddLogFile(filename, *logMaxSize); err != nil { |
|
|
|
|
panic(err) |
|
|
|
|
} |
|
|
|
|
if *onlyLogTps { |
|
|
|
|
matchFilterHandler := log.MatchFilterHandler("msg", "TPS Report", utils.GetLogInstance().GetHandler()) |
|
|
|
|
utils.GetLogInstance().SetHandler(matchFilterHandler) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Start Profiler for leader if profile argument is on
|
|
|
|
|
if nodeConfig.StringRole == "leader" && (*profile || *metricsReportURL != "") { |
|
|
|
|