Skip to content
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

ErrorHandler #569

Open
GanBob opened this issue Jul 27, 2023 · 2 comments
Open

ErrorHandler #569

GanBob opened this issue Jul 27, 2023 · 2 comments

Comments

@GanBob
Copy link

GanBob commented Jul 27, 2023

please,I want a private ErrorHandler,not global

func (e *Event) msg(msg string) {
	for _, hook := range e.ch {
		hook.Run(e, e.level, msg)
	}
	if msg != "" {
		e.buf = enc.AppendString(enc.AppendKey(e.buf, MessageFieldName), msg)
	}
	if e.done != nil {
		defer e.done(msg)
	}
	if err := e.write(); err != nil {
		if ErrorHandler != nil {   //why here is a global ErrorHandler?
			ErrorHandler(err)
		} else {
			fmt.Fprintf(os.Stderr, "zerolog: could not write event: %v\n", err)
		}
	}
}
@mitar
Copy link
Contributor

mitar commented Aug 18, 2023

Maybe explain a bit your use case? Why you do not want global error handler? Logging is generally done for the whole program globally?

@GanBob
Copy link
Author

GanBob commented Aug 25, 2023

Thank you for your reply.In my usage scenario, I will connect to multiple different syslog servers at the same time. If one of the services is abnormal, I cannot handle it specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants