/
main.go
54 lines (46 loc) · 1.01 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
49
50
51
52
53
54
package main
import (
"context"
"fmt"
"log"
"os"
_ "github.com/Ak-Army/go-cluster-ssh/cmd"
"github.com/Ak-Army/go-cluster-ssh/internal"
"github.com/Ak-Army/cli"
"github.com/Ak-Army/xlog"
)
func main() {
l := initLogger()
/*config.LoadVccConfig(AppName)
if err != nil {
log.Fatal(err)
}*/
l.SetField("version", internal.Version)
l.SetField("pid", fmt.Sprintf("%d", os.Getpid()))
l.Info("start...")
ctx := xlog.NewContext(context.Background(), l)
c := cli.New("go-cluster-ssh", internal.Version)
cli.RootCommand().Authors = []string{"Ak-Army"}
c.SetDefault("run")
c.Run(ctx, os.Args)
}
func initLogger() xlog.Logger {
xlog.SetLogger(xlog.NopLogger)
multiOutput := xlog.MultiOutput{}
multiOutput = append(multiOutput, xlog.NewConsoleOutput())
level := xlog.LevelInfo
for _, v := range os.Args {
if v == "-v" {
level = xlog.LevelDebug
}
}
conf := xlog.Config{
Level: level,
Output: multiOutput,
}
log.SetFlags(0)
l := xlog.New(conf)
xlog.SetLogger(l)
log.SetOutput(l)
return l
}