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 logging calls from library code #334

Open
tchap opened this issue Feb 13, 2025 · 3 comments
Open

Remove logging calls from library code #334

tchap opened this issue Feb 13, 2025 · 3 comments

Comments

@tchap
Copy link
Contributor

tchap commented Feb 13, 2025

Some parts of the codebase contain logging calls right before returning an error to the caller.
This library code (e.g. interface implementation) should probably just return the error and let the caller do logging.

Issue created based on #330 (comment)

@kfswain
Copy link
Collaborator

kfswain commented Feb 19, 2025

I'm not sure if this is needed. I don't mind the logs tbh. LMKWYT tho

While the quote is rather opinionated, I do think it makes a fair point. Pulled from: https://github.com/go-logr/logr?tab=readme-ov-file#a-minimal-logging-api-for-go

Many people assert that libraries should not be logging, and as such efforts like this are pointless. Those people are welcome to convince the authors of the tens-of-thousands of libraries that DO write logs that they are all wrong. In the meantime, logr takes a more practical approach.

@tchap
Copy link
Contributor Author

tchap commented Feb 19, 2025

I'm not sure if this is needed. I don't mind the logs tbh. LMKWYT tho

Yeah, this is clearly not black and white. I just created the issue to evaluate this later.

What I meant are logging calls where you do

  1. Log error.
  2. Return the error to the caller.
  3. Log the error right again.

This is just spamming logs.

But generally speaking, the context can be different for both calls, you can know different things at different places. I guess this is also a reason why logs are sometimes associated with a trace ID within the whole telemetry so that you can link multiple log entries together. This might actually be a more interesting question. Can we link multiple log entries together?

@kfswain
Copy link
Collaborator

kfswain commented Feb 19, 2025

Ahh yes, this SGTM for sure. I'll leave this open and we can revisit as needed.

I don't have a strong opinion for now, I think as the product matures and we go through debugging pain we will have more opinions.

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