control/controlclient: use structured logging for MapResponse.ControlTime
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
committed by
Josh Bleecher Snyder
parent
84138450a4
commit
823d970d60
@@ -213,6 +213,7 @@ type LogCatcher struct {
|
||||
buf bytes.Buffer
|
||||
gotErr error
|
||||
reqs int
|
||||
raw bool // indicates whether to store the raw JSON logs uploaded, instead of just the text
|
||||
}
|
||||
|
||||
// UseLogf makes the logcatcher implementation use a given logf function
|
||||
@@ -223,6 +224,13 @@ func (lc *LogCatcher) UseLogf(fn logger.Logf) {
|
||||
lc.logf = fn
|
||||
}
|
||||
|
||||
// StoreRawJSON instructs lc to save the raw JSON uploads, rather than just the text.
|
||||
func (lc *LogCatcher) StoreRawJSON() {
|
||||
lc.mu.Lock()
|
||||
defer lc.mu.Unlock()
|
||||
lc.raw = true
|
||||
}
|
||||
|
||||
func (lc *LogCatcher) logsContains(sub mem.RO) bool {
|
||||
lc.mu.Lock()
|
||||
defer lc.mu.Unlock()
|
||||
@@ -315,6 +323,10 @@ func (lc *LogCatcher) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
id := privID.Public().String()[:3] // good enough for integration tests
|
||||
for _, ent := range jreq {
|
||||
if lc.raw {
|
||||
lc.buf.Write(bodyBytes)
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(&lc.buf, "%s\n", strings.TrimSpace(ent.Text))
|
||||
if lc.logf != nil {
|
||||
lc.logf("logcatch:%s: %s", id, strings.TrimSpace(ent.Text))
|
||||
|
||||
Reference in New Issue
Block a user