From 0c03d2729460d572ef1bae3cb23a4d90b0d9b14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20St=C3=A4ber?= Date: Tue, 28 May 2019 11:28:47 +0200 Subject: [PATCH] #5 debugging failing tailer test on Darwin --- tailer/fswatcher/fseventProducerLoop_darwin.go | 4 +--- tailer/fswatcher/fswatcher_darwin.go | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tailer/fswatcher/fseventProducerLoop_darwin.go b/tailer/fswatcher/fseventProducerLoop_darwin.go index 3d7bce43..34f24247 100644 --- a/tailer/fswatcher/fseventProducerLoop_darwin.go +++ b/tailer/fswatcher/fseventProducerLoop_darwin.go @@ -26,8 +26,6 @@ type keventloop struct { done chan struct{} } -type Kevent syscall.Kevent_t - // Terminate the kevent loop. // If the loop hangs in syscall.Kevent(), it will keep hanging there until the next event is read. // Therefore, after the consumer called Close(), it should interrupt the kevent() call by closing the kq descriptor. @@ -86,7 +84,7 @@ func runKeventLoop(kq int) *keventloop { return result } -func (event Kevent) String() string { +func event2string(event syscall.Kevent_t) string { result := make([]string, 0, 1) if event.Fflags&syscall.NOTE_DELETE == syscall.NOTE_DELETE { result = append(result, "NOTE_DELETE") diff --git a/tailer/fswatcher/fswatcher_darwin.go b/tailer/fswatcher/fswatcher_darwin.go index 875bf246..f3b4b9cb 100644 --- a/tailer/fswatcher/fswatcher_darwin.go +++ b/tailer/fswatcher/fswatcher_darwin.go @@ -120,14 +120,14 @@ func (w *watcher) processEvent(t *fileTailer, event fsevent, log logrus.FieldLog for _, dir = range t.watchedDirs { if kevent.Ident == fdToInt(dir.file.Fd()) { dirLogger = log.WithField("directory", dir.file.Name()) - dirLogger.Debugf("dir event: %v", kevent) + dirLogger.Debugf("dir event: %v", event2string(kevent)) return w.processDirEvent(t, kevent, dir, dirLogger) } } for _, file = range t.watchedFiles { if kevent.Ident == fdToInt(file.file.Fd()) { fileLogger = log.WithField("file", file.file.Name()).WithField("fd", file.file.Fd()) - fileLogger.Debugf("file event: %v", kevent) + fileLogger.Debugf("file event: %v", event2string(kevent)) return w.processFileEvent(t, kevent, file, fileLogger) } }