(t *testing.T)
| 657 | } |
| 658 | |
| 659 | func TestLoggerAddCallerFunction(t *testing.T) { |
| 660 | tests := []struct { |
| 661 | options []Option |
| 662 | loggerFunction string |
| 663 | sugaredFunction string |
| 664 | }{ |
| 665 | { |
| 666 | options: opts(), |
| 667 | loggerFunction: "", |
| 668 | sugaredFunction: "", |
| 669 | }, |
| 670 | { |
| 671 | options: opts(WithCaller(false)), |
| 672 | loggerFunction: "", |
| 673 | sugaredFunction: "", |
| 674 | }, |
| 675 | { |
| 676 | options: opts(AddCaller()), |
| 677 | loggerFunction: "go.uber.org/zap.infoLog", |
| 678 | sugaredFunction: "go.uber.org/zap.infoLogSugared", |
| 679 | }, |
| 680 | { |
| 681 | options: opts(AddCaller(), WithCaller(false)), |
| 682 | loggerFunction: "", |
| 683 | sugaredFunction: "", |
| 684 | }, |
| 685 | { |
| 686 | options: opts(WithCaller(true)), |
| 687 | loggerFunction: "go.uber.org/zap.infoLog", |
| 688 | sugaredFunction: "go.uber.org/zap.infoLogSugared", |
| 689 | }, |
| 690 | { |
| 691 | options: opts(WithCaller(true), WithCaller(false)), |
| 692 | loggerFunction: "", |
| 693 | sugaredFunction: "", |
| 694 | }, |
| 695 | { |
| 696 | options: opts(AddCaller(), AddCallerSkip(1), AddCallerSkip(-1)), |
| 697 | loggerFunction: "go.uber.org/zap.infoLog", |
| 698 | sugaredFunction: "go.uber.org/zap.infoLogSugared", |
| 699 | }, |
| 700 | { |
| 701 | options: opts(AddCaller(), AddCallerSkip(2)), |
| 702 | loggerFunction: "go.uber.org/zap.withLogger", |
| 703 | sugaredFunction: "go.uber.org/zap.withLogger", |
| 704 | }, |
| 705 | { |
| 706 | options: opts(AddCaller(), AddCallerSkip(2), AddCallerSkip(3)), |
| 707 | loggerFunction: "runtime.goexit", |
| 708 | sugaredFunction: "runtime.goexit", |
| 709 | }, |
| 710 | } |
| 711 | for _, tt := range tests { |
| 712 | withLogger(t, DebugLevel, tt.options, func(logger *Logger, logs *observer.ObservedLogs) { |
| 713 | // Make sure that sugaring and desugaring resets caller skip properly. |
| 714 | logger = logger.Sugar().Desugar() |
| 715 | infoLog(logger, "") |
| 716 | infoLogSugared(logger.Sugar(), "") |
nothing calls this directly
no test coverage detected