merge upstream

Signed-off-by: wozulong <>
This commit is contained in:
wozulong
2024-04-28 14:04:19 +08:00
15 changed files with 86 additions and 37 deletions

View File

@@ -2,6 +2,7 @@ package common
import (
"context"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"io"
@@ -99,6 +100,7 @@ func LogQuota(quota int) string {
}
}
func LogQuotaF(quota float64) string {
if DisplayInCurrencyEnabled {
return fmt.Sprintf("%.6f 额度", quota/QuotaPerUnit)
@@ -106,3 +108,14 @@ func LogQuotaF(quota float64) string {
return fmt.Sprintf("%d 点额度", int64(quota))
}
}
// LogJson 仅供测试使用 only for test
func LogJson(ctx context.Context, msg string, obj any) {
jsonStr, err := json.Marshal(obj)
if err != nil {
LogError(ctx, fmt.Sprintf("json marshal failed: %s", err.Error()))
return
}
LogInfo(ctx, fmt.Sprintf("%s | %s", msg, string(jsonStr)))
}