enhance(log):改进对于空白指针类型的日志输出。

This commit is contained in:
徐涛 2023-06-11 17:50:40 +08:00
parent 7476278c52
commit cadb2db8c7

View File

@ -139,7 +139,7 @@ func DecimalField(key string, val decimal.Decimal) zap.Field {
func DecimalFieldp(key string, val *decimal.Decimal) zap.Field { func DecimalFieldp(key string, val *decimal.Decimal) zap.Field {
if val == nil { if val == nil {
return zap.String(key, "null") return zap.Stringp(key, nil)
} }
return DecimalField(key, *val) return DecimalField(key, *val)
} }
@ -148,17 +148,17 @@ func NullDecimalField(key string, val decimal.NullDecimal) zap.Field {
if val.Valid { if val.Valid {
return DecimalField(key, val.Decimal) return DecimalField(key, val.Decimal)
} }
return zap.String(key, "null") return zap.Stringp(key, nil)
} }
func NullDecimalFieldp(key string, val *decimal.NullDecimal) zap.Field { func NullDecimalFieldp(key string, val *decimal.NullDecimal) zap.Field {
if val == nil { if val == nil {
return zap.String(key, "null") return zap.Stringp(key, nil)
} }
if val.Valid { if val.Valid {
return DecimalField(key, val.Decimal) return DecimalField(key, val.Decimal)
} }
return zap.String(key, "null") return zap.Stringp(key, nil)
} }
func DateField(key string, val types.Date) zap.Field { func DateField(key string, val types.Date) zap.Field {
@ -167,7 +167,7 @@ func DateField(key string, val types.Date) zap.Field {
func DateFieldp(key string, val *types.Date) zap.Field { func DateFieldp(key string, val *types.Date) zap.Field {
if val == nil { if val == nil {
return zap.String(key, "null") return zap.Stringp(key, nil)
} }
return DateField(key, *val) return DateField(key, *val)
} }
@ -178,7 +178,7 @@ func DateTimeField(key string, val types.DateTime) zap.Field {
func DateTimeFieldp(key string, val *types.DateTime) zap.Field { func DateTimeFieldp(key string, val *types.DateTime) zap.Field {
if val == nil { if val == nil {
return zap.String(key, "null") return zap.Stringp(key, nil)
} }
return DateTimeField(key, *val) return DateTimeField(key, *val)
} }