-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何获取原始参数 #104
Comments
handler 这里拿不到了, args 已经被格式化到 record.Message 了 |
是否有别的方法可以拿到,便于判断是否需要做通知 @inhere |
这种情况应该设置 context data 或者 extra 数据, 使用更方便: // add log
slog.WithData(slog.M{"notify": true}).Info("some message")
// in handler
func (n *notify) Handle(record *slog.Record) error {
notify := record.Data["notify"]
if notify {
// do something ...
}
return nil
} |
@inhere 需要做以上两个处理才可以。 如果能在record 拿到args,那改动就很小, |
记录下 args 也可以,我下个版本在 record 加个 |
发了 v0.5.2, logger 新增了选项: // BackupArgs backup log input args to Record.Args
BackupArgs bool |
slog.PushHandlers(handler...)
在record 如何获取
slog.Error
传入的argsThe text was updated successfully, but these errors were encountered: