Commit 67be6bbd authored by Jeromy's avatar Jeromy

skip logs when no writers connected

License: MIT
Signed-off-by: default avatarJeromy <jeromyj@gmail.com>
parent 90896f28
......@@ -83,6 +83,11 @@ func (el *eventLogger) EventBegin(ctx context.Context, event string, metadata ..
func (el *eventLogger) Event(ctx context.Context, event string, metadata ...Loggable) {
// short circuit if theres nothing to write to
if !WriterGroup.Active() {
return
}
// Collect loggables for later logging
var loggables []Loggable
......
......@@ -29,3 +29,10 @@ func (mw *MirrorWriter) AddWriter(w io.Writer) {
mw.writers = append(mw.writers, w)
mw.lk.Unlock()
}
func (mw *MirrorWriter) Active() (active bool) {
mw.lk.Lock()
active = len(mw.writers) > 0
mw.lk.Unlock()
return
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment