ditointernet / go-dito

MIT License
6 stars 0 forks source link

fix: fixing panic when type assertion a non-string attribute #73

Open lincolnjunior7 opened 1 year ago

lincolnjunior7 commented 1 year ago

When trying to use package go-dito/log to log a value whose type is an struct type, the function buildOtelAttributes panics. This occurs beacause this function is trying to do a type assertion with a value that is not a string. In case it is not the intended behavior, maybe we can fix that by replacing this type assertion with a call to fmt.Sprintf, using the verb %+v. This way, string type attributes will still work and struct type attributes will be used as its default string representation (if that rerepresentation is not sufficient, one can override it, defining a String() method, since the %v check if type implements the Stringer interface)