-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calm down OCR's logging unless VerboseLogging or TraceLogging is enabled
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package llo | ||
|
||
import "github.com/smartcontractkit/chainlink-common/pkg/logger" | ||
|
||
// Suppressed logger swallows debug/info unless the verbose flag is turned on | ||
// Useful for OCR to calm down its verbosity | ||
|
||
var _ logger.Logger = &SuppressedLogger{} | ||
|
||
func NewSuppressedLogger(lggr logger.Logger, verbose bool) logger.Logger { | ||
return &SuppressedLogger{ | ||
Logger: lggr, | ||
Verbose: verbose, | ||
} | ||
} | ||
|
||
type SuppressedLogger struct { | ||
logger.Logger | ||
Verbose bool | ||
} | ||
|
||
func (s *SuppressedLogger) Debug(args ...interface{}) { | ||
if s.Verbose { | ||
s.Logger.Debug(args...) | ||
} | ||
} | ||
func (s *SuppressedLogger) Info(args ...interface{}) { | ||
if s.Verbose { | ||
s.Logger.Info(args...) | ||
} | ||
} | ||
func (s *SuppressedLogger) Debugf(format string, values ...interface{}) { | ||
if s.Verbose { | ||
s.Logger.Debugf(format, values...) | ||
} | ||
} | ||
func (s *SuppressedLogger) Infof(format string, values ...interface{}) { | ||
if s.Verbose { | ||
s.Logger.Infof(format, values...) | ||
} | ||
} | ||
func (s *SuppressedLogger) Debugw(msg string, keysAndValues ...interface{}) { | ||
if s.Verbose { | ||
s.Logger.Debugw(msg, keysAndValues...) | ||
} | ||
} | ||
func (s *SuppressedLogger) Infow(msg string, keysAndValues ...interface{}) { | ||
if s.Verbose { | ||
s.Logger.Infow(msg, keysAndValues...) | ||
} | ||
} |