Skip to content

Change log writing to a single statement (don't split query/args) #499

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

Open
natdm opened this issue Mar 20, 2019 · 3 comments
Open

Change log writing to a single statement (don't split query/args) #499

natdm opened this issue Mar 20, 2019 · 3 comments

Comments

@natdm
Copy link

natdm commented Mar 20, 2019

What version of SQLBoiler are you using (sqlboiler --version)? 3

Running sql queries concurrently log the queries and arguments in random order
eg:

SELECT WHERE...
SELECT WHERE...
[1212]
[1315]
SELECT WHERE ...
[1111]

Proposal:
Safer concurrent logging and don't separate the query and the args

@aarondl
Copy link
Member

aarondl commented Mar 20, 2019

You can replace the logger with whatever you'd like so long as it conforms to the io.Writer interface in order to make it goroutine safe:
https://github.com/volatiletech/sqlboiler/blob/master/boil/global.go#L25

Not separating query and args could definitely be done but it will make it harder to see. Certainly you cannot put a newline between them in a log because some people may be using structured logging adapters that may not play nice with that sort of thing. Although maybe it'd be escaped. Open to suggestions here.

@natdm
Copy link
Author

natdm commented Apr 17, 2019

I think it might be more about the fact that they make multiple writes at the same time (and can be done safely) but then they intertwine with each-other, making the logs useless to read since you don't know what is doing what with which arguments. Maybe the solution is to do something like sarama.Logger, which can easily be replaced with log.New(), or zap.Logger.Sugar(), and then can be written to with formatted lines.

@aarondl
Copy link
Member

aarondl commented May 20, 2019

@natdm Still happy to accept a PR to merge these outputs into a single call to log.

@aarondl aarondl changed the title Concurrent Log Writes Change log writing to a single statement (don't split query/args) Aug 26, 2019
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