@@ -265,9 +265,7 @@ func (l *logrusAdapter) Tracef(format string, args ...any) {
265265//
266266// logger.WithField("user_id", 42).Info("User logged in")
267267func (l * logrusAdapter ) WithField (key string , value any ) Logger {
268- * l = logrusAdapter {entry : l .entry .Dup ().WithField (key , value )}
269-
270- return l
268+ return & logrusAdapter {entry : l .entry .WithField (key , value )}
271269}
272270
273271// WithFields returns a new Logger instance with multiple key-value pairs added to the log context.
@@ -280,9 +278,7 @@ func (l *logrusAdapter) WithField(key string, value any) Logger {
280278//
281279// logger.WithFields(map[string]any{"user_id": 42, "role": "admin"}).Info("Access granted")
282280func (l * logrusAdapter ) WithFields (fields map [string ]any ) Logger {
283- * l = logrusAdapter {entry : l .entry .Dup ().WithFields (fields )}
284-
285- return l
281+ return & logrusAdapter {entry : l .entry .WithFields (fields )}
286282}
287283
288284// WithRequestStringID returns a new Logger instance with a string request ID added to the context.
@@ -295,9 +291,7 @@ func (l *logrusAdapter) WithFields(fields map[string]any) Logger {
295291//
296292// logger.WithRequestStringID("req-123").Info("Request started")
297293func (l * logrusAdapter ) WithRequestStringID (id string ) Logger {
298- * l = logrusAdapter {entry : l .entry .Dup ().WithField (KeyRequestID , id )}
299-
300- return l
294+ return & logrusAdapter {entry : l .entry .WithField (KeyRequestID , id )}
301295}
302296
303297// WithRequestUUID returns a new Logger instance with a UUID-based request ID added to the context.
@@ -310,9 +304,7 @@ func (l *logrusAdapter) WithRequestStringID(id string) Logger {
310304//
311305// logger.WithRequestUUID(uuid.New()).Info("Tracking UUID request")
312306func (l * logrusAdapter ) WithRequestUUID (id uuid.UUID ) Logger {
313- * l = logrusAdapter {entry : l .entry .Dup ().WithField (KeyRequestID , id )}
314-
315- return l
307+ return & logrusAdapter {entry : l .entry .WithField (KeyRequestID , id )}
316308}
317309
318310// WithRequestID returns a new Logger instance with a numeric request ID added to the context.
@@ -325,9 +317,7 @@ func (l *logrusAdapter) WithRequestUUID(id uuid.UUID) Logger {
325317//
326318// logger.WithRequestID(1001).Info("Handling request")
327319func (l * logrusAdapter ) WithRequestID (id uint64 ) Logger {
328- * l = logrusAdapter {entry : l .entry .Dup ().WithField (KeyRequestID , id )}
329-
330- return l
320+ return & logrusAdapter {entry : l .entry .WithField (KeyRequestID , id )}
331321}
332322
333323// WithRandomRequestID returns a new Logger instance with a randomly generated numeric request ID.
@@ -336,9 +326,7 @@ func (l *logrusAdapter) WithRequestID(id uint64) Logger {
336326//
337327// logger.WithRandomRequestID().Info("Generated random request ID")
338328func (l * logrusAdapter ) WithRandomRequestID () Logger {
339- * l = logrusAdapter {entry : l .entry .Dup ().WithField (KeyRequestID , rand .Uint64 ())}
340-
341- return l
329+ return & logrusAdapter {entry : l .entry .WithField (KeyRequestID , rand .Uint64 ())}
342330}
343331
344332// WithSystemRequestID returns a new Logger instance with a system configuration ID added to the context.
@@ -351,9 +339,7 @@ func (l *logrusAdapter) WithRandomRequestID() Logger {
351339//
352340// logger.WithSystemRequestID(3).Info("Using config #3")
353341func (l * logrusAdapter ) WithSystemRequestID (id uint8 ) Logger {
354- * l = logrusAdapter {entry : l .entry .Dup ().WithField (KeySystemRequestID , id )}
355-
356- return l
342+ return & logrusAdapter {entry : l .entry .WithField (KeySystemRequestID , id )}
357343}
358344
359345// WithUserID returns a new Logger instance with a user ID added to the log context.
@@ -366,9 +352,7 @@ func (l *logrusAdapter) WithSystemRequestID(id uint8) Logger {
366352//
367353// logger.WithUserID(12345).Info("User performed action")
368354func (l * logrusAdapter ) WithUserID (userID uint64 ) Logger {
369- * l = logrusAdapter {entry : l .entry .Dup ().WithField (KeyUserID , userID )}
370-
371- return l
355+ return & logrusAdapter {entry : l .entry .WithField (KeyUserID , userID )}
372356}
373357
374358// GetFields returns the current log context fields as a map.
0 commit comments