Skip to content

Commit

Permalink
Merge pull request #134 from rsergeychik/fix-float32-log-field-converter
Browse files Browse the repository at this point in the history
fix float32 zapcore field converter
  • Loading branch information
vmihailenco authored Sep 22, 2024
2 parents 20a3da6 + da07ee0 commit ac7e808
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion otelzap/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ func appendField(kvs []log.KeyValue, f zapcore.Field) []log.KeyValue {
zapcore.UintptrType:
return append(kvs, log.Int64(f.Key, f.Integer))

case zapcore.Float32Type, zapcore.Float64Type:
case zapcore.Float64Type:
num := math.Float64frombits(uint64(f.Integer))
return append(kvs, log.Float64(f.Key, num))
case zapcore.Float32Type:
num := math.Float32frombits(uint32(f.Integer))
return append(kvs, log.Float64(f.Key, float64(num)))

case zapcore.Complex64Type:
str := strconv.FormatComplex(complex128(f.Interface.(complex64)), 'E', -1, 64)
Expand Down

0 comments on commit ac7e808

Please sign in to comment.