-
Notifications
You must be signed in to change notification settings - Fork 75
/
main.go
51 lines (38 loc) · 951 Bytes
/
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
49
50
51
package main
import (
"os"
"fmt"
"github.com/ipfs/go-log"
"github.com/keep-network/keep-common/pkg/logging"
"github.com/keep-network/keep-core/build"
"github.com/keep-network/keep-core/cmd"
"github.com/keep-network/keep-core/config"
)
//go:generate make gen_proto
var logger = log.Logger("keep-main")
func main() {
configureLogging()
rootCmd := cmd.Initialize(build.Version, build.Revision)
if err := rootCmd.Execute(); err != nil {
logger.Fatal(err)
}
}
func configureLogging() {
logLevel := "info"
if env := os.Getenv(config.LogLevelEnvVariable); len(env) > 0 {
logLevel = env
}
pubsubLogLevel := "warn"
if env := os.Getenv(config.PubsubLogLevelEnvVariable); len(env) > 0 {
pubsubLogLevel = env
}
levelDirective := fmt.Sprintf(
"%s pubsub=%s",
logLevel,
pubsubLogLevel,
)
err := logging.Configure(levelDirective)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to configure logging: [%v]\n", err)
}
}