title: CGO and Logging
body: <p>I'm about to adopt an enhaced logging library in a Go codebase, I've reduced my scope to <a href="https://github.com/mgutz/logxi" rel="nofollow">logxi</a> and <a href="https://github.com/inconshreveable/log15" rel="nofollow">log15</a>. Even though they seem quite new, I like the <a href="https://brandur.org/logfmt" rel="nofollow">logfmt</a> enforcement offered by them, although each has its advantages and disadvantages. Anyway, even bringing the simpler standard logging facility to the question, an issue remains.</p>
  
  <p>I'm mixing Go and C++ a lot (through C bridges and CGO). I'm facing the issue of whether I should make Go callbacks for logging from C++ or logging straight from C++, which would make me miss the library pattern adopted in Go. In any case, let's say I'm talking about logging to stdout, I'm still unsure how to proceed with a best option about having synchronized output, since it's both Go and C land and I'll have some threads looping in C while some goroutines running on its own. By adopting the callbacks this may not be an issue, but it may be expensive... Also wrapping a logging facility for C is problematic since they generally provide a variadic API in Go.</p>