logs for pods are better formatted
This commit is contained in:
@@ -145,3 +145,17 @@ func (a *ArgoLogs) StopStepRecording(current *ArgoWatch) *ArgoWatch {
|
||||
current.Status = status
|
||||
return current
|
||||
}
|
||||
|
||||
type ArgoPodLog struct {
|
||||
PodName string
|
||||
Step string
|
||||
Message string
|
||||
}
|
||||
|
||||
func NewArgoPodLog(name string, step string, msg string) ArgoPodLog {
|
||||
return ArgoPodLog{
|
||||
PodName: name,
|
||||
Step: step,
|
||||
Message: msg,
|
||||
}
|
||||
}
|
@@ -18,7 +18,7 @@ var wfLogger zerolog.Logger
|
||||
|
||||
|
||||
// Take the slice of string that make up one round of stderr outputs from the --watch option in argo submit
|
||||
func NewLocalArgoLogs(inputs []string) *ArgoWatch {
|
||||
func NewLocalArgoWatch(inputs []string) *ArgoWatch {
|
||||
var workflow ArgoWatch
|
||||
|
||||
for _, input := range inputs {
|
||||
@@ -84,7 +84,7 @@ func LogLocalWorkflow(wfName string, pipe io.ReadCloser, wg *sync.WaitGroup) {
|
||||
// Log the progress of the WF
|
||||
if strings.HasPrefix(log, "Progress:") {
|
||||
|
||||
current_watch = *NewLocalArgoLogs(watch_output)
|
||||
current_watch = *NewLocalArgoWatch(watch_output)
|
||||
workflowName := current_watch.Name
|
||||
if !current_watch.Equals(&previous_watch) {
|
||||
wg.Add(1)
|
||||
@@ -106,17 +106,24 @@ func LogLocalWorkflow(wfName string, pipe io.ReadCloser, wg *sync.WaitGroup) {
|
||||
}
|
||||
|
||||
// Debug, no logs sent
|
||||
func LogPods(pipe io.ReadCloser, steps []string, wg *sync.WaitGroup) {
|
||||
func LogPods(wfName string, pipe io.ReadCloser, steps []string, wg *sync.WaitGroup) {
|
||||
scanner := bufio.NewScanner(pipe)
|
||||
for scanner.Scan() {
|
||||
var podLogger zerolog.Logger
|
||||
fmt.Println("new line")
|
||||
wg.Add(1)
|
||||
var podLogger zerolog.Logger
|
||||
|
||||
line := scanner.Text()
|
||||
podName := strings.Split(line, ":")[0]
|
||||
podLogger = wfLogger.With().Str("step_name", getStepName(podName, steps)).Logger()
|
||||
log := strings.Split(line,podName+":")[1]
|
||||
podLogger.Info().Msg(log)
|
||||
podLog := NewArgoPodLog(wfName,podName,log)
|
||||
jsonifiedLog, err := json.Marshal(podLog)
|
||||
if err != nil {
|
||||
podLogger.Fatal().Msg(err.Error())
|
||||
}
|
||||
|
||||
podLogger.Info().Msg(string(jsonifiedLog))
|
||||
wg.Done()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user