-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlog.go
50 lines (43 loc) · 866 Bytes
/
log.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
package main
import (
"log"
"strconv"
"strings"
"github.com/FurqanSoftware/bullet/core"
"github.com/FurqanSoftware/bullet/spec"
"github.com/spf13/cobra"
)
var LogTailCmd = &cobra.Command{
Use: "log",
Short: "Tail application log",
Long: `This command tails the application log.`,
Run: func(cmd *cobra.Command, args []string) {
spec, err := spec.ParseFile("Bulletspec")
if err != nil {
log.Fatal(err)
return
}
nodes, err := core.ParseNodeSet(Hosts, Port, Identity)
if err != nil {
log.Fatal(err)
return
}
parts := strings.SplitN(args[0], ":", 2)
no := 1
if len(parts) == 2 {
no, err = strconv.Atoi(parts[1])
if err != nil {
log.Fatal(err)
return
}
}
err = core.Log(nodes, spec, parts[0], no)
if err != nil {
log.Fatal(err)
return
}
},
}
func init() {
RootCmd.AddCommand(LogTailCmd)
}