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

logging library #15

Closed
dblooman opened this issue Sep 6, 2017 · 7 comments
Closed

logging library #15

dblooman opened this issue Sep 6, 2017 · 7 comments

Comments

@dblooman
Copy link
Contributor

dblooman commented Sep 6, 2017

The logging library used in this SDK is pretty terrible. I would to use a custom logger or at least have something that isn't using inline XML configuration, its 2017.

@luluzhao
Copy link
Contributor

luluzhao commented Sep 6, 2017

Hi Dave, Thank you for using xray Go SDK and I would like to hear why you think the logging library is bad? Is it only the configuration bothering you?

@cep21
Copy link
Contributor

cep21 commented Sep 6, 2017

The use of global mutable state is one concern I have.

@dlsniper
Copy link

dlsniper commented Sep 6, 2017

@luluzhao probably the best way to solve this would be to allow users to inject an io.Writer implementation for a custom logger.

I've almost finished a refactoring to do so, but it's pretty big. In it also gets a bit into the other issue #11 due to how it works.

@dblooman
Copy link
Contributor Author

I'm using Apex for lambda functions using Go. Apex requires the default output for logging to be STDERR, not STDOUT. It appears that you are setting the console write explicitly. I would be good to have some control over the type of output, to disable it completely would useful during testing.

If we could either remove this library and replace it with something more customisable, or just use the stdlib, that would be appreciated. There is not enough control with the SDK in its current form.

@sthulb
Copy link
Contributor

sthulb commented Sep 25, 2017

I guess ideally, the SDK would accept an interface for logging, or use the standard "log" pkg if none is specified

@rantav
Copy link

rantav commented Sep 27, 2017

FWIW, as a temporary workaround I wrote the following function, which simply shuts the logger up.

import "github.com/cihub/seelog"

func ShutTheFuckUp() {
	config := `
<seelog type="sync" minlevel="off">
	<outputs><console/></outputs>
</seelog>`

	logger, err := seelog.LoggerFromConfigAsBytes([]byte(config))
	if err != nil {
		panic(err)
	}
	seelog.ReplaceLogger(logger)
}

@muirdm
Copy link
Contributor

muirdm commented Jan 24, 2019

Here are some problems with the logger:

  1. No way to log to a file
  2. No way to disable logging
  3. Use of global seelog logger is dangerous/naughty (i.e. if the user of xray happens to also use the global seelog logger, xray will overwrite the user's logger)
  4. Configuring log level to "error", I still see an "info" level message every time because something logs at the default level before the config is updated.

As others have mentioned, a better way is to accept a logger interface. I recommend a custom interface (e.g. with Debug(), Info() and Error() methods), but io.Writer or stdlib *log.Logger would still be a major improvement. You can maintain the current default behavior of logging to stdout.

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

7 participants