You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I think it could be useful to have at least three new methods in the log package:
AsyncPrint(v ...interface{})
AsyncPrintf(format string, v ...interface{})
AsyncPrintln(v ...interface{})
these methods should produce the same output of the respective synchronous methods, but the operations will be performed in a separated goroutine.
The same methods should also be added to the Logger type.
The implementation of these methods can be realized using a buffered channel in which messages to be logged are written and a consumer goroutine reads the requests and write the logs. The maximum limit of requests in the buffer should be configurable.
Best regards,
Massimo
The text was updated successfully, but these errors were encountered:
Yes it's correct, but all major logging libraries offer the ability to write log asynchronously, it seems unusual that Go does not provide "natively" even using a different approach from what I've described.
You might have a point, but your API proposal is not what we'd do in Go and distracts from the problem.
You could imagine a new constructor or setter method in the log package to enable N bytes of in-memory buffering before pushback occurs.
Do you have an implementation? A proof of concept outside the standard library would be a requirement to adding anything to the standard library anyway.
Let's move this discussion to a forum (see https://golang.org/wiki/Questions) for now, though, because I imagine this has come up before.
If the golang-nuts@ thread yields any new info, the summary of that information can be posted here and we can reconsider.
Hi,
I think it could be useful to have at least three new methods in the log package:
these methods should produce the same output of the respective synchronous methods, but the operations will be performed in a separated goroutine.
The same methods should also be added to the Logger type.
The implementation of these methods can be realized using a buffered channel in which messages to be logged are written and a consumer goroutine reads the requests and write the logs. The maximum limit of requests in the buffer should be configurable.
Best regards,
Massimo
The text was updated successfully, but these errors were encountered: