Skip to content

Commit

Permalink
Merge pull request #59 from purpleidea/feat/nilformatter
Browse files Browse the repository at this point in the history
capnslog: Add NilFormatter for silencing unwanted log messages
  • Loading branch information
jonboulle committed May 9, 2016
2 parents 506a84c + ffeb647 commit 160ae62
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions capnslog/formatters.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,23 @@ func (lf *LogFormatter) Format(pkg string, _ LogLevel, _ int, entries ...interfa
func (lf *LogFormatter) Flush() {
// noop
}

// NilFormatter is a no-op log formatter that does nothing.
type NilFormatter struct {
}

// NewNilFormatter is a helper to produce a new LogFormatter struct. It logs no
// messages so that you can cause part of your logging to be silent.
func NewNilFormatter() Formatter {
return &NilFormatter{}
}

// Format does nothing.
func (_ *NilFormatter) Format(_ string, _ LogLevel, _ int, _ ...interface{}) {
// noop
}

// Flush is included so that the interface is complete, but is a no-op.
func (_ *NilFormatter) Flush() {
// noop
}

0 comments on commit 160ae62

Please sign in to comment.