(sender byte, encodedLen int32, msgType string, writeDetails func())
| 361 | } |
| 362 | |
| 363 | func (t *tracer) writeTrace(sender byte, encodedLen int32, msgType string, writeDetails func()) { |
| 364 | t.mux.Lock() |
| 365 | defer t.mux.Unlock() |
| 366 | defer func() { |
| 367 | if t.buf.Cap() > 1024 { |
| 368 | t.buf = &bytes.Buffer{} |
| 369 | } else { |
| 370 | t.buf.Reset() |
| 371 | } |
| 372 | }() |
| 373 | |
| 374 | if !t.SuppressTimestamps { |
| 375 | now := time.Now() |
| 376 | t.buf.WriteString(now.Format("2006-01-02 15:04:05.000000")) |
| 377 | t.buf.WriteByte('\t') |
| 378 | } |
| 379 | |
| 380 | t.buf.WriteByte(sender) |
| 381 | t.buf.WriteByte('\t') |
| 382 | t.buf.WriteString(msgType) |
| 383 | t.buf.WriteByte('\t') |
| 384 | t.buf.WriteString(strconv.FormatInt(int64(encodedLen), 10)) |
| 385 | |
| 386 | if writeDetails != nil { |
| 387 | writeDetails() |
| 388 | } |
| 389 | |
| 390 | t.buf.WriteByte('\n') |
| 391 | t.buf.WriteTo(t.w) |
| 392 | } |
| 393 | |
| 394 | // traceDoubleQuotedString returns t.buf as a double-quoted string without any escaping. It is roughly equivalent to |
| 395 | // pqTraceOutputString in libpq. |
no test coverage detected