diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index fc7bf24a2..be49fbdf3 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -34,6 +34,7 @@ https://github.com/elastic/apm-agent-go/compare/v1.15.0...main[View commits] - Replace apm.DefaultTracer with an initialization function {pull}1189[#(1189)] - Remove transport.Default, construct a new Transport in each new tracer {pull}1195[#(1195)] - Add service name and version to User-Agent header {pull}1196[#(1196)] +- Remove WarningLogger, add Warningf methe to Logger {pull}1205[#(1205)] - Replace Sampler with ExtendedSampler {pull}1206[#(1206)] [[release-notes-1.x]] diff --git a/apmtest/testlogger.go b/apmtest/testlogger.go index e1faf44f7..f9e5e08af 100644 --- a/apmtest/testlogger.go +++ b/apmtest/testlogger.go @@ -38,6 +38,11 @@ func (t TestLogger) Errorf(format string, args ...interface{}) { t.l.Logf("[ERROR] "+format, args...) } +// Warningf logs warning messages. +func (t TestLogger) Warningf(format string, args ...interface{}) { + t.l.Logf("[WARNING] "+format, args...) +} + // LogfLogger is an interface with the a Logf method, // implemented by *testing.T and *testing.B. type LogfLogger interface { diff --git a/config.go b/config.go index 65d2e1465..16963d157 100644 --- a/config.go +++ b/config.go @@ -387,7 +387,7 @@ func initialExitSpanMinDuration() (time.Duration, error) { // config for config attributes that have been removed (exist in old but not in attrs). // // On return from updateRemoteConfig, unapplied config will have been removed from attrs. -func (t *Tracer) updateRemoteConfig(logger WarningLogger, old, attrs map[string]string) { +func (t *Tracer) updateRemoteConfig(logger Logger, old, attrs map[string]string) { warningf := func(string, ...interface{}) {} debugf := func(string, ...interface{}) {} errorf := func(string, ...interface{}) {} diff --git a/logger.go b/logger.go index a9485c79c..929c2f914 100644 --- a/logger.go +++ b/logger.go @@ -25,30 +25,7 @@ type Logger interface { // Errorf logs a message at error level. Errorf(format string, args ...interface{}) -} - -// WarningLogger extends Logger with a Warningf method. -// -// TODO(axw) this will be removed in v2.0.0, and the -// Warningf method will be added directly to Logger. -type WarningLogger interface { - Logger // Warningf logs a message at warning level. Warningf(format string, args ...interface{}) } - -func makeWarningLogger(l Logger) WarningLogger { - if wl, ok := l.(WarningLogger); ok { - return wl - } - return debugWarningLogger{Logger: l} -} - -type debugWarningLogger struct { - Logger -} - -func (l debugWarningLogger) Warningf(format string, args ...interface{}) { - l.Debugf(format, args...) -} diff --git a/tracer.go b/tracer.go index 7ff09c75a..6bdee261c 100644 --- a/tracer.go +++ b/tracer.go @@ -535,7 +535,7 @@ type tracerConfig struct { requestSize int requestDuration time.Duration metricsInterval time.Duration - logger WarningLogger + logger Logger metricsGatherers []MetricsGatherer disabledMetrics wildcard.Matchers cpuProfileDuration time.Duration @@ -617,15 +617,12 @@ func (t *Tracer) SetMetricsInterval(d time.Duration) { // SetLogger sets the Logger to be used for logging the operation of // the tracer. // -// If logger implements WarningLogger, its Warningf method will be used -// for logging warnings. Otherwise, warnings will logged using Debugf. -// // The tracer is initialized with a default logger configured with the // environment variables ELASTIC_APM_LOG_FILE and ELASTIC_APM_LOG_LEVEL. // Calling SetLogger will replace the default logger. func (t *Tracer) SetLogger(logger Logger) { t.sendConfigCommand(func(cfg *tracerConfig) { - cfg.logger = makeWarningLogger(logger) + cfg.logger = logger }) }