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

os/glog: When should I use Writer , and when should I use Handler ? Why? #3877

Open
RyoJerryYu opened this issue Oct 21, 2024 · 1 comment
Open

Comments

@RyoJerryYu
Copy link

What do you want to ask?

Writer and Handler seem to have a lot of overlapping responsibilities. In fact, they both have an example code in documentation that do the exactly same thing that write logs to Graylog.

So, why there are two method to do the same work? What's the difference? Which is the recommended one?

@gqcn
Copy link
Member

gqcn commented Oct 24, 2024

@RyoJerryYu Hello,

  • The Writer is an underlying interface, which just accepts the content bytes and outputs to the destination you can customize.
  • The Handler is a more higher level callback function in which you can customize the logging content, color, prefix, etc. It is more flexable and extensible than Writer.

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

No branches or pull requests

2 participants