diff --git a/pkg/services/publicdashboards/database/database.go b/pkg/services/publicdashboards/database/database.go index 7c396e5cc07..270b033cb09 100644 --- a/pkg/services/publicdashboards/database/database.go +++ b/pkg/services/publicdashboards/database/database.go @@ -21,6 +21,8 @@ type PublicDashboardStoreImpl struct { dialect migrator.Dialect } +var LogPrefix = "publicdashboards.store" + // Gives us a compile time error if our database does not adhere to contract of // the interface var _ publicdashboards.Store = (*PublicDashboardStoreImpl)(nil) @@ -29,7 +31,7 @@ var _ publicdashboards.Store = (*PublicDashboardStoreImpl)(nil) func ProvideStore(sqlStore *sqlstore.SQLStore) *PublicDashboardStoreImpl { return &PublicDashboardStoreImpl{ sqlStore: sqlStore, - log: log.New("publicdashboards.store"), + log: log.New(LogPrefix), dialect: sqlStore.Dialect, } } diff --git a/pkg/services/publicdashboards/database/database_test.go b/pkg/services/publicdashboards/database/database_test.go index 092e3226dde..6aa9f032fb4 100644 --- a/pkg/services/publicdashboards/database/database_test.go +++ b/pkg/services/publicdashboards/database/database_test.go @@ -24,6 +24,10 @@ var DefaultTimeSettings, _ = simplejson.NewJson([]byte(`{}`)) // Default time to pass in with seconds rounded var DefaultTime = time.Now().UTC().Round(time.Second) +func TestLogPrefix(t *testing.T) { + assert.Equal(t, LogPrefix, "publicdashboards.store") +} + func TestIntegrationGetDashboard(t *testing.T) { var sqlStore *sqlstore.SQLStore var dashboardStore *dashboardsDB.DashboardStore diff --git a/pkg/services/publicdashboards/service/service.go b/pkg/services/publicdashboards/service/service.go index 2b3a2168390..3c204a4c463 100644 --- a/pkg/services/publicdashboards/service/service.go +++ b/pkg/services/publicdashboards/service/service.go @@ -25,6 +25,8 @@ type PublicDashboardServiceImpl struct { store publicdashboards.Store } +var LogPrefix = "publicdashboards.service" + // Gives us compile time error if the service does not adhere to the contract of // the interface var _ publicdashboards.Service = (*PublicDashboardServiceImpl)(nil) @@ -36,7 +38,7 @@ func ProvideService( store publicdashboards.Store, ) *PublicDashboardServiceImpl { return &PublicDashboardServiceImpl{ - log: log.New("publicdashboards"), + log: log.New(LogPrefix), cfg: cfg, store: store, } diff --git a/pkg/services/publicdashboards/service/service_test.go b/pkg/services/publicdashboards/service/service_test.go index 9d7f8b70792..23e63f36078 100644 --- a/pkg/services/publicdashboards/service/service_test.go +++ b/pkg/services/publicdashboards/service/service_test.go @@ -27,6 +27,10 @@ var defaultPubdashTimeSettings, _ = simplejson.NewJson([]byte(`{}`)) var dashboardData = simplejson.NewFromAny(map[string]interface{}{"time": map[string]interface{}{"from": "now-8", "to": "now"}}) var mergedDashboardData = simplejson.NewFromAny(map[string]interface{}{"time": map[string]interface{}{"from": "now-12", "to": "now"}}) +func TestLogPrefix(t *testing.T) { + assert.Equal(t, LogPrefix, "publicdashboards.service") +} + func TestGetPublicDashboard(t *testing.T) { type storeResp struct { pd *PublicDashboard