diff --git a/logger/core.go b/logger/core.go index ee23acd9..0dbe8cdb 100644 --- a/logger/core.go +++ b/logger/core.go @@ -1,6 +1,8 @@ package logger import ( + "runtime/debug" + "go.uber.org/zap" "go.uber.org/zap/zapcore" ) @@ -36,7 +38,7 @@ func (c *core) Write(e zapcore.Entry, fields []zapcore.Field) error { zap.Object("context", report), // see: https://cloud.google.com/error-reporting/docs/formatting-error-messages#log-error // see: https://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.events/report#ReportedErrorEvent - zap.String("stack_trace", e.Message+"\n"+e.Stack), + zap.String("stack_trace", e.Message+"\n"+string(debug.Stack())), ) } } diff --git a/logger/logger.go b/logger/logger.go index b8eff5fc..e319a80f 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -40,7 +40,6 @@ func newLogger(w io.Writer, lvl zapcore.LevelEnabler) *Logger { core := newCore(zapcore.NewCore(enc, ws, lvl)) opts := []zap.Option{ zap.AddCaller(), - zap.AddStacktrace(zapcore.ErrorLevel), } logger := zap.New(core, opts...) @@ -119,7 +118,7 @@ func newEncoderConfig() zapcore.EncoderConfig { NameKey: "logger", CallerKey: "", MessageKey: "message", - StacktraceKey: "", + StacktraceKey: "stacktrace", LineEnding: zapcore.DefaultLineEnding, EncodeLevel: encodeLevel, EncodeTime: zapcore.RFC3339NanoTimeEncoder,