bearslyricattack commented on code in PR #7: URL: https://github.com/apache/incubator-seata-ctl/pull/7#discussion_r1811075545
########## action/log/log.go: ########## @@ -0,0 +1,180 @@ +package log + +import ( + "fmt" + "github.com/seata/seata-ctl/action/log/utils" + "github.com/seata/seata-ctl/action/log/utils/impl" + "github.com/seata/seata-ctl/model" + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" + "log" + "os" +) + +const ( + ElasticSearchType = "ElasticSearch" + DefaultNumber = 10 +) +const ( + LokiType = "Loki" +) + +var LogCmd = &cobra.Command{ + Use: "log", + Short: "get seata log", + Run: func(cmd *cobra.Command, args []string) { + err := getLog() + if err != nil { + fmt.Println(err) + } + }, +} + +// ElasticSearch + +var LogLevel string +var Module string +var XID string +var BranchID string +var ResourceID string +var Message string +var Number int + +// Loki + +var Label string +var Start string +var End string + +func init() { + LogCmd.PersistentFlags().StringVar(&LogLevel, "Level", "", "seata log level") + LogCmd.PersistentFlags().StringVar(&Module, "Module", "", "seata module") + LogCmd.PersistentFlags().StringVar(&XID, "XID", "", "seata expression") + LogCmd.PersistentFlags().StringVar(&BranchID, "BranchID", "", "seata branchId") + LogCmd.PersistentFlags().StringVar(&ResourceID, "ResourceID", "", "seata resourceID") + LogCmd.PersistentFlags().StringVar(&Message, "Message", "", "seata message") + LogCmd.PersistentFlags().IntVar(&Number, "Number", DefaultNumber, "seata number") + LogCmd.PersistentFlags().StringVar(&Label, "label", "", "seata label") + LogCmd.PersistentFlags().StringVar(&Start, "start", "", "seata start") + LogCmd.PersistentFlags().StringVar(&End, "end", "", "seata end") +} + +func getLog() error { + context, currency, err := getContext() + if err != nil { + return err + } + logType := context.Types + + var client utils.LogQuery + var filter = make(map[string]interface{}) + + switch logType { + case ElasticSearchType: + { + client = &impl.Elasticsearch{} + filter = buildElasticSearchFilter() + } + case LokiType: + { + client = &impl.Loki{} + filter = buildLokiFilter() + } + //case "Local": + // { + // return &impl.Local{}, nil, nil + // } Review Comment: Already deleted -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@seata.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@seata.apache.org For additional commands, e-mail: dev-h...@seata.apache.org