github.com/newrelic/go-agent@v3.26.0+incompatible/log.go (about) 1 // Copyright 2020 New Relic Corporation. All rights reserved. 2 // SPDX-License-Identifier: Apache-2.0 3 4 package newrelic 5 6 import ( 7 "io" 8 9 "github.com/newrelic/go-agent/internal/logger" 10 ) 11 12 // Logger is the interface that is used for logging in the go-agent. Assign the 13 // Config.Logger field to the Logger you wish to use. Loggers must be safe for 14 // use in multiple goroutines. Two Logger implementations are included: 15 // NewLogger, which logs at info level, and NewDebugLogger which logs at debug 16 // level. logrus and logxi are supported by the integration packages 17 // https://godoc.org/github.com/newrelic/go-agent/_integrations/nrlogrus and 18 // https://godoc.org/github.com/newrelic/go-agent/_integrations/nrlogxi/v1. 19 type Logger interface { 20 Error(msg string, context map[string]interface{}) 21 Warn(msg string, context map[string]interface{}) 22 Info(msg string, context map[string]interface{}) 23 Debug(msg string, context map[string]interface{}) 24 DebugEnabled() bool 25 } 26 27 // NewLogger creates a basic Logger at info level. 28 func NewLogger(w io.Writer) Logger { 29 return logger.New(w, false) 30 } 31 32 // NewDebugLogger creates a basic Logger at debug level. 33 func NewDebugLogger(w io.Writer) Logger { 34 return logger.New(w, true) 35 }