@@ -71,10 +71,12 @@ func Test_Logger_WithError(t *testing.T) {
7171 a .Regexp (`^time.* level\=error msg\=oops error\="found an error: an error occurred"` , b .String ())
7272}
7373
74- type identifiable struct {}
74+ type identifiable struct {
75+ value string
76+ }
7577
7678func (i identifiable ) LogIdentity () map [string ]any {
77- return map [string ]any {"field" : " value" }
79+ return map [string ]any {"field" : i . value }
7880}
7981
8082func Test_Logger_With (t * testing.T ) {
@@ -84,10 +86,24 @@ func Test_Logger_With(t *testing.T) {
8486 logrusLogger .Out = & out
8587 logger := Logger {Logger : logrusLogger }
8688
87- i := identifiable {}
89+ i := identifiable {value : "__value__" }
8890 logger .With (i ).Info ("message" )
8991
90- a .Contains (out .String (), "field=value" )
92+ a .Contains (out .String (), "field=__value__" )
93+ }
94+
95+ func Test_Logger_With_MergesMultipleObjects (t * testing.T ) {
96+ a := assert .New (t )
97+ var out strings.Builder
98+ logrusLogger := logrus .New ()
99+ logrusLogger .Out = & out
100+ logger := Logger {Logger : logrusLogger }
101+
102+ logger .
103+ With (identifiable {value : "__overwritten__" }, identifiable {value : "__value__" }).
104+ Info ("message" )
105+
106+ a .Contains (out .String (), "field=__value__" )
91107}
92108
93109func Test_Logger_Call (t * testing.T ) {
0 commit comments