@@ -3,6 +3,7 @@ package cmd
4 "encoding/json"
4 "encoding/json"
6 "path/filepath"
7 "path/filepath"
@@ -26,16 +27,22 @@ var logsCmd = &cobra.Command{
26 if err != nil {
27 if err != nil {
27 return fmt.Errorf("failed to get current working directory: %v", err)
28 return fmt.Errorf("failed to get current working directory: %v", err)
30+ log.SetLevel(log.DebugLevel)
29 cfg, err := config.Load(cwd, false)
31 cfg, err := config.Load(cwd, false)
30 if err != nil {
32 if err != nil {
31 return fmt.Errorf("failed to load configuration: %v", err)
33 return fmt.Errorf("failed to load configuration: %v", err)
35+ logsFile := filepath.Join(cfg.WorkingDir(), cfg.Options.DataDirectory, "logs", "crush.log")
36+ _, err = os.Stat(logsFile)
37+ if os.IsNotExist(err) {
38+ log.Warn("Looks like you are not in a crush project. No logs found.")
33− t, err := tail.TailFile(filepath.Join(cfg.Options.DataDirectory, "logs", "crush.log"), tail.Config{Follow: true, ReOpen: true, Logger: tail.DiscardingLogger})
41+ t, err := tail.TailFile(logsFile, tail.Config{Follow: true, ReOpen: true, Logger: tail.DiscardingLogger})
34 if err != nil {
42 if err != nil {
35 return fmt.Errorf("failed to tail log file: %v", err)
43 return fmt.Errorf("failed to tail log file: %v", err)
38− log.SetLevel(log.DebugLevel)
39 // Print the text of each received line
46 // Print the text of each received line
40 for line := range t.Lines {
47 for line := range t.Lines {
41 var data map[string]any
48 var data map[string]any