diff options
author | Florian Klink <flokli@flokli.de> | 2023-10-20T12·18+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-10-30T09·07+0000 |
commit | 9a1e5cf4c731c082032285e9b02e453fd0d11483 (patch) | |
tree | 7c6a265f3ee80146275a621154196d1f31fa170a /third_party/gerrit-queue/misc/rotatingloghandler.go | |
parent | 2513ddd2b7559628a0135ec0c8e4e8ea4444af8d (diff) |
chore(third_party/gerrit-queue): move to tvl overlay r/6906
Bump to a version including https://github.com/flokli/gerrit-queue/pull/15 Change-Id: Ie316498ca2c608e5489901c5705ce5f2dc047f29 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9808 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/gerrit-queue/misc/rotatingloghandler.go')
-rw-r--r-- | third_party/gerrit-queue/misc/rotatingloghandler.go | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/third_party/gerrit-queue/misc/rotatingloghandler.go b/third_party/gerrit-queue/misc/rotatingloghandler.go deleted file mode 100644 index 3d4c5f3a837a..000000000000 --- a/third_party/gerrit-queue/misc/rotatingloghandler.go +++ /dev/null @@ -1,34 +0,0 @@ -package misc - -import ( - "sync" - - "github.com/apex/log" -) - -// RotatingLogHandler implementation. -type RotatingLogHandler struct { - mu sync.Mutex - Entries []*log.Entry - maxEntries int -} - -// NewRotatingLogHandler creates a new rotating log handler -func NewRotatingLogHandler(maxEntries int) *RotatingLogHandler { - return &RotatingLogHandler{ - maxEntries: maxEntries, - } -} - -// HandleLog implements log.Handler. -func (h *RotatingLogHandler) HandleLog(e *log.Entry) error { - h.mu.Lock() - defer h.mu.Unlock() - // drop tail if we have more entries than maxEntries - if len(h.Entries) > h.maxEntries { - h.Entries = append([]*log.Entry{e}, h.Entries[:(h.maxEntries-2)]...) - } else { - h.Entries = append([]*log.Entry{e}, h.Entries...) - } - return nil -} |