Skip to content

Commit

Permalink
Merge pull request #716 from ww24/disable-zap-stacktrace
Browse files Browse the repository at this point in the history
fix(logger): disable zap stacktrace
  • Loading branch information
ww24 authored Sep 26, 2023
2 parents 91a3400 + 620d17c commit 6818cd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion logger/core.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package logger

import (
"runtime/debug"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
Expand Down Expand Up @@ -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())),
)
}
}
Expand Down
3 changes: 1 addition & 2 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)

Expand Down Expand Up @@ -119,7 +118,7 @@ func newEncoderConfig() zapcore.EncoderConfig {
NameKey: "logger",
CallerKey: "",
MessageKey: "message",
StacktraceKey: "",
StacktraceKey: "stacktrace",
LineEnding: zapcore.DefaultLineEnding,
EncodeLevel: encodeLevel,
EncodeTime: zapcore.RFC3339NanoTimeEncoder,
Expand Down

0 comments on commit 6818cd5

Please sign in to comment.