updated to stdout + file logger

pull/7/head
Richard Liu 6 years ago
parent 1d0f62ff00
commit 83364e487d
  1. 11
      benchmark_main.go

@ -3,12 +3,14 @@ package main
import ( import (
"bufio" "bufio"
"flag" "flag"
"fmt"
"harmony-benchmark/consensus" "harmony-benchmark/consensus"
"harmony-benchmark/log" "harmony-benchmark/log"
"harmony-benchmark/node" "harmony-benchmark/node"
"harmony-benchmark/p2p" "harmony-benchmark/p2p"
"os" "os"
"strings" "strings"
"time"
) )
func getShardId(myIp, myPort string, config *[][]string) string { func getShardId(myIp, myPort string, config *[][]string) string {
@ -59,8 +61,13 @@ func readConfigFile(configFile string) [][]string {
} }
func main() { func main() {
// Setup a stdout logger // Setup a logger to stdout and log file.
h := log.CallerFileHandler(log.StdoutHandler) logFileName := fmt.Sprintf("./%v.log", time.Now().Format("20060102150405"))
h := log.MultiHandler(
log.Must.FileHandler(logFileName, log.LogfmtFormat()),
log.StdoutHandler)
// In cases where you just want a stdout logger, use the following one instead.
// h := log.CallerFileHandler(log.StdoutHandler)
log.Root().SetHandler(h) log.Root().SetHandler(h)
ip := flag.String("ip", "127.0.0.1", "IP of the node") ip := flag.String("ip", "127.0.0.1", "IP of the node")

Loading…
Cancel
Save