forked from filecoin-project/venus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (40 loc) · 1.63 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"os"
"strconv"
logging "github.com/ipfs/go-log"
oldlogging "github.com/whyrusleeping/go-logging"
"github.com/filecoin-project/go-filecoin/commands"
"github.com/filecoin-project/go-filecoin/metrics"
)
func main() {
// TODO: make configurable - this should be done via a command like go-ipfs
// something like:
// `go-filecoin log level "system" "level"`
// TODO: find a better home for this
// TODO fix this in go-log 4 == INFO
n, err := strconv.Atoi(os.Getenv("GO_FILECOIN_LOG_LEVEL"))
if err != nil {
n = 4
}
if os.Getenv("GO_FILECOIN_LOG_JSON") == "1" {
oldlogging.SetFormatter(&metrics.JSONFormatter{})
}
logging.SetAllLoggers(oldlogging.Level(n))
logging.SetLogLevel("dht", "error") // nolint: errcheck
logging.SetLogLevel("bitswap", "error") // nolint: errcheck
logging.SetLogLevel("heartbeat", "error") // nolint: errcheck
logging.SetLogLevel("blockservice", "error") // nolint: errcheck
logging.SetLogLevel("peerqueue", "error") // nolint: errcheck
logging.SetLogLevel("swarm", "error") // nolint: errcheck
logging.SetLogLevel("swarm2", "error") // nolint: errcheck
logging.SetLogLevel("basichost", "error") // nolint: errcheck
logging.SetLogLevel("dht_net", "error") // nolint: errcheck
logging.SetLogLevel("pubsub", "error") // nolint: errcheck
logging.SetLogLevel("relay", "error") // nolint: errcheck
// TODO implement help text like so:
// https://github.com/ipfs/go-ipfs/blob/master/core/commands/root.go#L91
// TODO don't panic if run without a command.
code, _ := commands.Run(os.Args, os.Stdin, os.Stdout, os.Stderr)
os.Exit(code)
}