forked from derailed/k9s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (44 loc) · 995 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 (
"flag"
"os"
"github.com/derailed/k9s/cmd"
"github.com/derailed/k9s/internal/config"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/klog/v2"
)
func init() {
config.EnsurePath(config.K9sLogs, config.DefaultDirMod)
}
func init() {
klog.InitFlags(nil)
if err := flag.Set("logtostderr", "false"); err != nil {
panic(err)
}
if err := flag.Set("alsologtostderr", "false"); err != nil {
panic(err)
}
if err := flag.Set("stderrthreshold", "fatal"); err != nil {
panic(err)
}
if err := flag.Set("v", "0"); err != nil {
panic(err)
}
if err := flag.Set("log_file", config.K9sLogs); err != nil {
panic(err)
}
}
func main() {
mod := os.O_CREATE | os.O_APPEND | os.O_WRONLY
file, err := os.OpenFile(config.K9sLogs, mod, config.DefaultFileMod)
defer func() {
_ = file.Close()
}()
if err != nil {
panic(err)
}
log.Logger = log.Output(zerolog.ConsoleWriter{Out: file})
cmd.Execute()
}