diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f31a807..91588e3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ ## [unreleased] ### Features - [#358](https://github.com/influxdata/influxdb-client-go/pull/358): - - Added possibility to set an application name, which will be part of the User-Agent HTTP header + - Added possibility to set an application name, which will be part of the User-Agent HTTP header: - Set using `Options.SetApplicationName` - - Error message is written to log if an application name is not set. + - Warning message is written to log if an application name is not set + - This may change to be logged as an error in a future release - Added example how to fully override `User-Agent` header using `Doer` interface ### Bug fixes diff --git a/client.go b/client.go index 8f9d4fc2..74e13cdb 100644 --- a/client.go +++ b/client.go @@ -146,7 +146,7 @@ func NewClientWithOptions(serverURL string, authToken string, options *Options) ilog.Infof("Using URL '%s'%s", serverURL, tokenStr) } if options.ApplicationName() == "" { - ilog.Error("Application name is not set") + ilog.Warn("Application name is not set") } return client } diff --git a/client_test.go b/client_test.go index 90ebf7ea..a6ed886c 100644 --- a/client_test.go +++ b/client_test.go @@ -7,6 +7,7 @@ package influxdb2 import ( "context" "fmt" + ilog "github.com/influxdata/influxdb-client-go/v2/log" "log" "net/http" "net/http/httptest" @@ -111,7 +112,7 @@ func TestUserAgent(t *testing.T) { var sb strings.Builder log.SetOutput(&sb) log.SetFlags(0) - c := NewClient(server.URL, "x") + c := NewClientWithOptions(server.URL, "x", DefaultOptions().SetLogLevel(ilog.WarningLevel)) assert.True(t, strings.Contains(sb.String(), "Application name is not set")) up, err := c.Ping(context.Background()) require.NoError(t, err)