-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathlogs.go
More file actions
executable file
·46 lines (38 loc) · 1.04 KB
/
logs.go
File metadata and controls
executable file
·46 lines (38 loc) · 1.04 KB
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
/*
Copyright (C) 2021-2023, Kubefirst
This program is licensed under MIT.
See the LICENSE file for more details.
*/
package cmd
import (
"fmt"
"github.com/konstructio/kubefirst/internal/progress"
"github.com/konstructio/kubefirst/internal/provisionLogs"
"github.com/nxadm/tail"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// infoCmd represents the info command
var logsCmd = &cobra.Command{
Use: "logs",
Short: "kubefirst real time logs",
Long: `kubefirst real time logs`,
RunE: func(_ *cobra.Command, _ []string) error {
provisionLogs.InitializeProvisionLogsTerminal()
go func() {
t, err := tail.TailFile(viper.GetString("k1-paths.log-file"), tail.Config{Follow: true, ReOpen: true})
if err != nil {
fmt.Printf("Error tailing log file: %v\n", err)
progress.Progress.Quit()
return
}
for line := range t.Lines {
provisionLogs.AddLog(line.Text)
}
}()
if _, err := provisionLogs.ProvisionLogs.Run(); err != nil {
return fmt.Errorf("failed to run provision logs: %w", err)
}
return nil
},
}