MCPcopy Create free account
hub / github.com/blues/note / defaultLogger

Function defaultLogger

lib/debug.go:199–217  ·  view source on GitHub ↗

Output a debug string to local buffering, in a synchronized manner, and enqueue it for background output on the console. We do this because many of our debug routines are done at interrupt level, and fmt.Printf is notoriously slow.

(ctx context.Context, format string, args ...interface{})

Source from the content-addressed store, hash-verified

197// output on the console. We do this because many of our debug routines are done at interrupt level,
198// and fmt.Printf is notoriously slow.
199func defaultLogger(ctx context.Context, format string, args ...interface{}) {
200 // Exit if not yet initialized
201 if !loggerInitialized {
202 defaultLoggerInit()
203 }
204
205 message := fmt.Sprintf(format, args...)
206
207 // Append to what's pending, unless the channel is full, in which case we drop it and move on
208 if synchronous {
209 fmt.Println(message)
210 } else {
211 select {
212 case loggerChannel <- message:
213 default:
214 // channel full
215 }
216 }
217}
218
219// Initialize for debugging
220func defaultLoggerInit() {

Callers 5

logDebugFunction · 0.85
logInfoFunction · 0.85
logWarnFunction · 0.85
logErrorFunction · 0.85

Calls 1

defaultLoggerInitFunction · 0.85

Tested by 1