log.go 853 B

123456789101112131415161718192021222324252627282930
  1. package newrelic
  2. import (
  3. "io"
  4. "github.com/newrelic/go-agent/internal/logger"
  5. )
  6. // Logger is the interface that is used for logging in the go-agent. Assign the
  7. // Config.Logger field to the Logger you wish to use. Loggers must be safe for
  8. // use in multiple goroutines.
  9. //
  10. // For an example implementation, see: _integrations/nrlogrus/nrlogrus.go
  11. type Logger interface {
  12. Error(msg string, context map[string]interface{})
  13. Warn(msg string, context map[string]interface{})
  14. Info(msg string, context map[string]interface{})
  15. Debug(msg string, context map[string]interface{})
  16. DebugEnabled() bool
  17. }
  18. // NewLogger creates a basic Logger at info level.
  19. func NewLogger(w io.Writer) Logger {
  20. return logger.New(w, false)
  21. }
  22. // NewDebugLogger creates a basic Logger at debug level.
  23. func NewDebugLogger(w io.Writer) Logger {
  24. return logger.New(w, true)
  25. }