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

Remove global logging functions in libbeat #15699

Closed
42 of 66 tasks
urso opened this issue Jan 21, 2020 · 2 comments
Closed
42 of 66 tasks

Remove global logging functions in libbeat #15699

urso opened this issue Jan 21, 2020 · 2 comments
Labels

Comments

@urso
Copy link

urso commented Jan 21, 2020

In order to better support structured logging, we want to get rid of the global logger functions. The API of the global logger functions is not in line with the methods defined by (*logp).Logger.

For now we will focus on libbeat first.

Refactoring Notes/Tips:

  • replace logp.Debug/Info/Warn/... with f variants like (*Logger).Debugf/Infof/Warnf/... if a format string has been used. Otherwise stick with (*Logger).Debug/Info/...
  • Use %+v when logging an error using a format string. Some logger libraries implement fmt.Formatter and will print the wrapped error only if + is given.
  • logp.Debug accepts as first argument the selector name. *logp.Logger instances have a name and the selector name must be removed when switching to (*Logger).Debugf
  • use (*Logger).Named (prefer (*Logger).Named) to create a logger instance in order to replace logp.MakeDebug. For now in unit tests you can use logp.L() if you need to pass a logger you don't care about
  • use logp.NewLogger to reduce the amount of transitive changes. NewLogger will be removed in the future as well, but for now it can help to reduce PR sizes.
  • store/pass logger instances locally. Do not store logger instances in private package global variables.
  • Use the compiler:
    • use tags=nologpglobal to compile/test a package without logp global logging functions being available
    • Do dependend packages still build?
  • Consider error values.
    • If we log a message without context and return an error value to be logged with a similar message, consider to just return the error value
    • If we log a message, but return the original error consider to remove the log message and wrap the error using an appropriate error message.

Tasks

@urso urso changed the title Remove global logging functions Remove global logging functions in libbeat Feb 14, 2020
simitt added a commit to simitt/beats that referenced this issue Mar 3, 2020
@andresrc andresrc added Team:Integrations Label for the Integrations team and removed Team:Beats labels Mar 6, 2020
@botelastic
Copy link

botelastic bot commented Jan 27, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@botelastic botelastic bot added the Stalled label Jan 27, 2022
@jlind23
Copy link
Collaborator

jlind23 commented Apr 1, 2022

Closing for now as all tasks listed were achieved.

@jlind23 jlind23 closed this as completed Apr 1, 2022
@zube zube bot added [zube]: Done and removed [zube]: Meta labels Apr 1, 2022
@zube zube bot removed the [zube]: Done label Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants