Просмотр исходного кода

fix: default request ID to 'SYSTEM' for background tasks

skynono 6 месяцев назад
Родитель
Сommit
b887db474e
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      common/logger.go

+ 3 - 0
common/logger.go

@@ -75,6 +75,9 @@ func logHelper(ctx context.Context, level string, msg string) {
 		writer = gin.DefaultWriter
 	}
 	id := ctx.Value(RequestIdKey)
+	if id == nil {
+		id = "SYSTEM"
+	}
 	now := time.Now()
 	_, _ = fmt.Fprintf(writer, "[%s] %v | %s | %s \n", level, now.Format("2006/01/02 - 15:04:05"), id, msg)
 	logCount++ // we don't need accurate count, so no lock here