@@ -280,40 +280,52 @@ func (l *Logger) Println(v ...any) {
280
280
281
281
// Fatal is equivalent to l.Print() followed by a call to [os.Exit](1).
282
282
func (l * Logger ) Fatal (v ... any ) {
283
- l .Output (2 , fmt .Sprint (v ... ))
283
+ l .output (0 , 2 , func (b []byte ) []byte {
284
+ return fmt .Append (b , v ... )
285
+ })
284
286
os .Exit (1 )
285
287
}
286
288
287
289
// Fatalf is equivalent to l.Printf() followed by a call to [os.Exit](1).
288
290
func (l * Logger ) Fatalf (format string , v ... any ) {
289
- l .Output (2 , fmt .Sprintf (format , v ... ))
291
+ l .output (0 , 2 , func (b []byte ) []byte {
292
+ return fmt .Appendf (b , format , v ... )
293
+ })
290
294
os .Exit (1 )
291
295
}
292
296
293
297
// Fatalln is equivalent to l.Println() followed by a call to [os.Exit](1).
294
298
func (l * Logger ) Fatalln (v ... any ) {
295
- l .Output (2 , fmt .Sprintln (v ... ))
299
+ l .output (0 , 2 , func (b []byte ) []byte {
300
+ return fmt .Appendln (b , v ... )
301
+ })
296
302
os .Exit (1 )
297
303
}
298
304
299
305
// Panic is equivalent to l.Print() followed by a call to panic().
300
306
func (l * Logger ) Panic (v ... any ) {
301
307
s := fmt .Sprint (v ... )
302
- l .Output (2 , s )
308
+ l .output (0 , 2 , func (b []byte ) []byte {
309
+ return append (b , s ... )
310
+ })
303
311
panic (s )
304
312
}
305
313
306
314
// Panicf is equivalent to l.Printf() followed by a call to panic().
307
315
func (l * Logger ) Panicf (format string , v ... any ) {
308
316
s := fmt .Sprintf (format , v ... )
309
- l .Output (2 , s )
317
+ l .output (0 , 2 , func (b []byte ) []byte {
318
+ return append (b , s ... )
319
+ })
310
320
panic (s )
311
321
}
312
322
313
323
// Panicln is equivalent to l.Println() followed by a call to panic().
314
324
func (l * Logger ) Panicln (v ... any ) {
315
325
s := fmt .Sprintln (v ... )
316
- l .Output (2 , s )
326
+ l .output (0 , 2 , func (b []byte ) []byte {
327
+ return append (b , s ... )
328
+ })
317
329
panic (s )
318
330
}
319
331
@@ -409,40 +421,52 @@ func Println(v ...any) {
409
421
410
422
// Fatal is equivalent to [Print] followed by a call to [os.Exit](1).
411
423
func Fatal (v ... any ) {
412
- std .Output (2 , fmt .Sprint (v ... ))
424
+ std .output (0 , 2 , func (b []byte ) []byte {
425
+ return fmt .Append (b , v ... )
426
+ })
413
427
os .Exit (1 )
414
428
}
415
429
416
430
// Fatalf is equivalent to [Printf] followed by a call to [os.Exit](1).
417
431
func Fatalf (format string , v ... any ) {
418
- std .Output (2 , fmt .Sprintf (format , v ... ))
432
+ std .output (0 , 2 , func (b []byte ) []byte {
433
+ return fmt .Appendf (b , format , v ... )
434
+ })
419
435
os .Exit (1 )
420
436
}
421
437
422
438
// Fatalln is equivalent to [Println] followed by a call to [os.Exit](1).
423
439
func Fatalln (v ... any ) {
424
- std .Output (2 , fmt .Sprintln (v ... ))
440
+ std .output (0 , 2 , func (b []byte ) []byte {
441
+ return fmt .Appendln (b , v ... )
442
+ })
425
443
os .Exit (1 )
426
444
}
427
445
428
446
// Panic is equivalent to [Print] followed by a call to panic().
429
447
func Panic (v ... any ) {
430
448
s := fmt .Sprint (v ... )
431
- std .Output (2 , s )
449
+ std .output (0 , 2 , func (b []byte ) []byte {
450
+ return append (b , s ... )
451
+ })
432
452
panic (s )
433
453
}
434
454
435
455
// Panicf is equivalent to [Printf] followed by a call to panic().
436
456
func Panicf (format string , v ... any ) {
437
457
s := fmt .Sprintf (format , v ... )
438
- std .Output (2 , s )
458
+ std .output (0 , 2 , func (b []byte ) []byte {
459
+ return append (b , s ... )
460
+ })
439
461
panic (s )
440
462
}
441
463
442
464
// Panicln is equivalent to [Println] followed by a call to panic().
443
465
func Panicln (v ... any ) {
444
466
s := fmt .Sprintln (v ... )
445
- std .Output (2 , s )
467
+ std .output (0 , 2 , func (b []byte ) []byte {
468
+ return append (b , s ... )
469
+ })
446
470
panic (s )
447
471
}
448
472
@@ -454,5 +478,8 @@ func Panicln(v ...any) {
454
478
// if [Llongfile] or [Lshortfile] is set; a value of 1 will print the details
455
479
// for the caller of Output.
456
480
func Output (calldepth int , s string ) error {
457
- return std .Output (calldepth + 1 , s ) // +1 for this frame.
481
+ calldepth ++ // +1 for this frame
482
+ return std .output (0 , calldepth , func (b []byte ) []byte {
483
+ return append (b , s ... )
484
+ })
458
485
}
0 commit comments