修复 journal 包的 log 参数名问题

This commit is contained in:
2025-08-19 11:29:35 +08:00
parent 0c32337168
commit 95c1a34ea4
2 changed files with 12 additions and 17 deletions

View File

@@ -89,7 +89,7 @@ func update(tx *gorm.DB, arg UpdateArgs) error {
count := len(gateways2Update)
if count > city.EdgesCount {
slog.Warn("城市节点数量不足,跳过本次更新", "城市", city.Name, "节点数", city.EdgesCount, "网关数", count)
slog.Warn(fmt.Sprintf("城市节点数量不足,跳过本次更新,城市:%s节点数%d网关数%d", city.Name, city.EdgesCount, count))
continue
}
@@ -98,7 +98,7 @@ func update(tx *gorm.DB, arg UpdateArgs) error {
return fmt.Errorf("查询城市 %s 可用节点失败:%w", city.Name, err)
}
if len(edges) < count {
slog.Debug("城市节点不足,将循环使用节点", "城市", city.Name, "节点数", city.EdgesCount, "网关数", count)
slog.Debug(fmt.Sprintf("城市节点不足,将循环使用节点,城市:%s节点数%d网关数%d", city.Name, city.EdgesCount, count))
edges, err = SliceActiveEdges(tx, city.Id, 0, count)
if err != nil {
return fmt.Errorf("查询城市 %s 可用节点失败:%w", city.Name, err)
@@ -117,7 +117,7 @@ func update(tx *gorm.DB, arg UpdateArgs) error {
newConfig := edges[iGateway]
if exists {
slog.Debug("网关配置变更", "网关", gateway.Macaddr, "旧节点", oldConfig.Macaddr, "新节点", newConfig.Macaddr)
slog.Debug(fmt.Sprintf("网关配置变更,网关:%s旧节点%s新节点%s", gateway.Macaddr, oldConfig.Macaddr, newConfig.Macaddr))
configs2Update = append(configs2Update, model.ConfigUpdate{
Id: oldConfig.Id,
@@ -133,7 +133,7 @@ func update(tx *gorm.DB, arg UpdateArgs) error {
},
}
} else {
slog.Debug("网关配置新增", "网关", gateway.Macaddr, "新节点", newConfig.Macaddr)
slog.Debug(fmt.Sprintf("网关配置新增,网关:%s新节点%s", gateway.Macaddr, newConfig.Macaddr))
configs2Create = append(configs2Create, model.Config{
Cityhash: city.Hash,
@@ -184,11 +184,11 @@ func update(tx *gorm.DB, arg UpdateArgs) error {
setup++
}
}
slog.Info("提交网关配置", "网关", gateway.Macaddr, "变更", change, "新增", setup)
slog.Info(fmt.Sprintf("提交网关配置,网关:%s变更数%d新增数%d", gateway.Macaddr, change, setup))
// 提交配置到云端:配置版本 gateway.ConfigVersion
if arg.Mock {
slog.Info("[MOCK] 配置网关", "网关", gateway.Macaddr, "配置", edges)
slog.Info(fmt.Sprintf("[MOCK] 配置网关,网关:%s配置%v", gateway.Macaddr, edges))
} else {
err := jd.GatewayConfigSet(gateway.ConfigVersion, gateway.Macaddr, edges)
if err != nil {