(t *testing.T)
| 737 | } |
| 738 | |
| 739 | func TestLoggerAddCallerFail(t *testing.T) { |
| 740 | errBuf := &ztest.Buffer{} |
| 741 | withLogger(t, DebugLevel, opts(AddCaller(), AddCallerSkip(1e3), ErrorOutput(errBuf)), func(log *Logger, logs *observer.ObservedLogs) { |
| 742 | log.Info("Failure.") |
| 743 | assert.Regexp( |
| 744 | t, |
| 745 | `Logger.check error: failed to get caller`, |
| 746 | errBuf.String(), |
| 747 | "Didn't find expected failure message.", |
| 748 | ) |
| 749 | assert.Equal( |
| 750 | t, |
| 751 | logs.AllUntimed()[0].Message, |
| 752 | "Failure.", |
| 753 | "Expected original message to survive failures in runtime.Caller.") |
| 754 | assert.Equal( |
| 755 | t, |
| 756 | logs.AllUntimed()[0].Caller.Function, |
| 757 | "", |
| 758 | "Expected function name to be empty string.") |
| 759 | }) |
| 760 | } |
| 761 | |
| 762 | func TestLoggerReplaceCore(t *testing.T) { |
| 763 | replace := WrapCore(func(zapcore.Core) zapcore.Core { |
nothing calls this directly
no test coverage detected