feat: Fine-tune logs presentation (#6771)

* Process debug mode logs

* Debug logs are grey

* Fix
This commit is contained in:
Marcin Tojek
2023-03-24 13:29:18 +01:00
committed by GitHub
parent c7fb5f960c
commit c9cbc63cd4
4 changed files with 29 additions and 3 deletions

View File

@ -347,7 +347,8 @@ func (api *API) followProvisionerJobLogs(actor rbac.Subject, jobID uuid.UUID) (<
logger := api.Logger.With(slog.F("job_id", jobID))
var (
bufferedLogs = make(chan *database.ProvisionerJobLog, 128)
// With debug logging enabled length = 128 is insufficient
bufferedLogs = make(chan *database.ProvisionerJobLog, 1024)
endOfLogs atomic.Bool
lastSentLogID atomic.Int64
)

View File

@ -460,7 +460,27 @@ func readAndLog(sink logSink, r io.Reader, done chan<- any, level proto.LogLevel
defer close(done)
scanner := bufio.NewScanner(r)
for scanner.Scan() {
var log terraformProvisionLog
err := json.Unmarshal(scanner.Bytes(), &log)
if err != nil {
if strings.TrimSpace(scanner.Text()) == "" {
continue
}
sink.Log(&proto.Log{Level: level, Output: scanner.Text()})
continue
}
logLevel := convertTerraformLogLevel(log.Level, sink)
if logLevel == proto.LogLevel_TRACE {
continue // skip TRACE log entries as they produce a lot of noise
}
// Degrade JSON log entries marked as INFO as these are logs produced in debug mode.
if logLevel == proto.LogLevel_INFO {
logLevel = proto.LogLevel_DEBUG
}
sink.Log(&proto.Log{Level: logLevel, Output: log.Message})
}
}

View File

@ -236,6 +236,7 @@ func provisionEnv(config *proto.Provision_Config, params []*proto.ParameterValue
for _, gitAuth := range gitAuth {
env = append(env, provider.GitAuthAccessTokenEnvironmentVariable(gitAuth.Id)+"="+gitAuth.AccessToken)
}
// FIXME env = append(env, "TF_LOG=JSON")
return env, nil
}

View File

@ -108,7 +108,11 @@ const useStyles = makeStyles<
backgroundColor: theme.palette.error.dark,
},
"&.warning": {
"&.debug": {
backgroundColor: theme.palette.grey[900],
},
"&.warn": {
backgroundColor: theme.palette.warning.dark,
},
},