Skip to content

Commit ec77f5b

Browse files
authored
improve the logging logic (#2002)
* improve user prompt content for ai summary
1 parent a8196fe commit ec77f5b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

backend/controllers/projects.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,14 @@ func (d DiggerController) SetJobStatusForProject(c *gin.Context) {
524524
return
525525
}
526526

527+
batchId := *job.BatchID
528+
527529
slog.Info("Processing job status update",
528530
"jobId", jobId,
529531
"currentStatus", job.Status,
530532
"newStatus", request.Status,
531533
"prCommentId", request.PrCommentId,
532-
"batchId", job.BatchID,
534+
"batchId", batchId,
533535
)
534536

535537
switch request.Status {
@@ -594,7 +596,7 @@ func (d DiggerController) SetJobStatusForProject(c *gin.Context) {
594596

595597
slog.Info("Job status updated to succeeded",
596598
"jobId", jobId,
597-
"batchId", job.BatchID,
599+
"batchId", batchId,
598600
)
599601

600602
go func() {
@@ -676,7 +678,7 @@ func (d DiggerController) SetJobStatusForProject(c *gin.Context) {
676678
slog.Info("Handling job completion",
677679
"jobId", jobId,
678680
"repoFullName", jobLink.RepoFullName,
679-
"batchId", job.BatchID,
681+
"batchId", batchId,
680682
)
681683

682684
err = services.DiggerJobCompleted(
@@ -721,7 +723,7 @@ func (d DiggerController) SetJobStatusForProject(c *gin.Context) {
721723

722724
slog.Info("Job status updated to failed",
723725
"jobId", jobId,
724-
"batchId", job.BatchID,
726+
"batchId", batchId,
725727
)
726728

727729
default:
@@ -1304,7 +1306,7 @@ func CreateTerraformOutputsSummary(gh utils.GithubClientProvider, batch *models.
13041306
"outputLength", len(job.TerraformOutput),
13051307
)
13061308

1307-
terraformOutputs += fmt.Sprintf("terraform output for %v \n\n", projectName) + job.TerraformOutput
1309+
terraformOutputs += fmt.Sprintf("<PLAN_START>terraform output for %v <PLAN_END>\n\n", projectName) + job.TerraformOutput
13081310
}
13091311

13101312
slog.Info("Generating AI summary from Terraform outputs",
@@ -1557,20 +1559,22 @@ func DeleteOlderPRCommentsIfEnabled(gh utils.GithubClientProvider, batch *models
15571559
// on whether or not its comments were deleted yet
15581560
err = prService.DeleteComment(strconv.FormatInt(*prJob.PRCommentId, 10))
15591561
if err != nil {
1560-
slog.Error("Could not delete comment for job", "jobID", prJob.ID, "commentID", prJob.PRCommentId, "error", err)
1562+
slog.Error("Could not delete comment for job", "jobID", prJob.ID, "commentID", *prJob.PRCommentId, "error", err)
15611563
allDeletesSuccessful = false
15621564
}
15631565
}
15641566
// delete previous summary table
15651567
if prBatch.CommentId != nil {
1568+
slog.Debug("Deleting summary comment for batch", "batchId", prBatch.ID, "commentID", prBatch.CommentId)
15661569
err = prService.DeleteComment(strconv.FormatInt(*prBatch.CommentId, 10))
15671570
if err != nil {
1568-
slog.Warn("Could not delete summary comment for batch", "batchId", prBatch.ID, "commentID", prBatch.CommentId, "error", err)
1571+
slog.Warn("Could not delete summary comment for batch", "batchId", prBatch.ID, "commentID", *prBatch.CommentId, "error", err)
15691572
}
15701573
}
15711574

15721575
// delete the summary comment
15731576
if prBatch.AiSummaryCommentId != "" {
1577+
slog.Debug("Deleting AI summary comment for batch", "batchId", prBatch.ID, "commentID", prBatch.AiSummaryCommentId)
15741578
err = prService.DeleteComment(prBatch.AiSummaryCommentId)
15751579
if err != nil {
15761580
slog.Warn("Could not delete AI summary comment for batch", "batchId", prBatch.ID, "commentID", prBatch.AiSummaryCommentId, "error", err)

0 commit comments

Comments
 (0)