mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
feat: Fine-tune logs presentation (#6771)
* Process debug mode logs * Debug logs are grey * Fix
This commit is contained in:
@ -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
|
||||
)
|
||||
|
@ -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})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user