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

Make logger configurable #104

Closed
andig opened this issue Apr 24, 2020 · 13 comments · Fixed by #180
Closed

Make logger configurable #104

andig opened this issue Apr 24, 2020 · 13 comments · Fixed by #180
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@andig
Copy link
Contributor

andig commented Apr 24, 2020

Usage of log.Logger is private and hard-wired. Would be helpful to set a custom logger.

@vlastahajek
Copy link
Contributor

@andig, thanks for the feedback. Such an item is already on our backlog. It could be in the next release.

@vlastahajek vlastahajek self-assigned this Apr 27, 2020
@vlastahajek vlastahajek added this to the v1.2.0 milestone Apr 27, 2020
@vlastahajek
Copy link
Contributor

@andig, what would you like to achieve with a custom logger?
Override complete messages by reimplementing Debug, Warn, etc., functions?
Or just redirect output from stderr to file, etc.?

@andig
Copy link
Contributor Author

andig commented Apr 30, 2020

Ideally I would like to chose what to log (info, debug etc). There is no common go standard for doing so afaik. So at least I would be able to set the logger instance (using Logger interface). I could then at least chose to set my TRACE logger instance.

@vlastahajek
Copy link
Contributor

Thanks for explaining your use case, understand.
Regarding what to log, I would like to check, whether are you aware of the ability to set debug level, or it doesn't suit your needs?

@andig
Copy link
Contributor Author

andig commented Apr 30, 2020

Noticed that, perfect.

@andig
Copy link
Contributor Author

andig commented May 1, 2020

I‘m using https://github.com/spf13/jwalterweatherman for my logging which is of course opinionated. One thing I cannot do with the influx log level is to differentiate which log level the client actually logs to when supplying a custom logger. That is still acceptable for time being.

@vlastahajek vlastahajek added the enhancement New feature or request label May 5, 2020
@vlastahajek vlastahajek modified the milestones: v1.2.0, v1.3.0 May 15, 2020
@vlastahajek vlastahajek modified the milestones: v1.3.0, v1.4.0 Jun 19, 2020
@andig
Copy link
Contributor Author

andig commented Jul 4, 2020

Regarding the upcoming 1.4 api, I feel this could be a very simple change:

	go func() {
		for err := range writer.Errors() {
			m.log.ERROR.Println(err)
		}
	}()

Why have the writer.Errors return a channel of

  • either structs containing error plus log level and
  • have the err as promoted field so compatibility remains

Would be happy to try a PR if this is the direction you'd like.

@andig
Copy link
Contributor Author

andig commented Jul 4, 2020

Actually, after looking at the source, the issue is at a deeper level. The Errors() interface will always return actual errors. What is missing is an abstraction of the logger to an interface and:

  • the ability to set a custom logger
  • allow setting logger to nil
  • controlling instantiation of a default logger

@andig andig mentioned this issue Jul 4, 2020
4 tasks
@andig
Copy link
Contributor Author

andig commented Jul 4, 2020

See #144 for a suggestion.

I've not happy with SetDebugLevel becoming part of the public API of the Logger interface (instead of client). Please let me know what you think- I'd propose to add an internal log adapter that translates SetDebugLevel into calls of the actual instantiated logger.

@andig
Copy link
Contributor Author

andig commented Jul 4, 2020

Updated #144 as suggested. Ready for review, sorry for the noise.

@Volcore
Copy link

Volcore commented Jul 16, 2020

I'd like to chime in here. I'd love to see the PR #144 make it through. Our influx server is down briefly every day as it's running on preemptive VMs, and that creates a lot of log spam on the writer side, which currently can not be disabled (as we can't set the log level to -1 or disable error logging in any way).

It even took us a while to figure out where the error logs are coming from, as they're unmarked and just said "[E] Write error" with some generic html error (as the load balancer was waiting for influx to come back), spammed over multiple lines, see below:

image

So, another side note is that the default errors should probably include some form of description of the source of the error (eg. "Influx write error" instead of "Write error").

@vlastahajek vlastahajek modified the milestones: v1.4.0, v1.5.0 Jul 19, 2020
@vlastahajek
Copy link
Contributor

@Volcore, the missing prefix will be added in the next release. There will also be an option to turn off logging, however, errors should be logged, because these are sign of sth not working ok.
The best solution would be to reconfigure the load balancer to return a JSON error message for REST API paths: /apiv/v2/*, /health, /ready, /setup

@Volcore
Copy link

Volcore commented Aug 17, 2020

Thanks for solving this! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants