Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit de5b567

Browse files
authored
Remove some uses of log15 (#45670)
1 parent 766c6c4 commit de5b567

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

cmd/frontend/internal/cli/serve_cmd.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
"github.com/getsentry/sentry-go"
1515
"github.com/graph-gophers/graphql-go"
16-
"github.com/inconshreveable/log15"
1716
"github.com/keegancsmith/tmpfriend"
1817
sglog "github.com/sourcegraph/log"
1918
"github.com/throttled/throttled/v2/store/redigostore"
@@ -124,7 +123,7 @@ func Main(enterpriseSetupHook func(database.DB, conftypes.UnifiedWatchable) ente
124123
observationCtx := observation.NewContext(logger)
125124

126125
if os.Getenv("SRC_DISABLE_OOBMIGRATION_VALIDATION") != "" {
127-
log15.Warn("Skipping out-of-band migrations check")
126+
logger.Warn("Skipping out-of-band migrations check")
128127
} else {
129128
outOfBandMigrationRunner := oobmigration.NewRunnerWithDB(observationCtx, db, oobmigration.RefreshInterval)
130129

@@ -261,12 +260,12 @@ func Main(enterpriseSetupHook func(database.DB, conftypes.UnifiedWatchable) ente
261260
return err
262261
}
263262

264-
server, err := makeExternalAPI(db, schema, enterprise, rateLimitWatcher)
263+
server, err := makeExternalAPI(db, logger, schema, enterprise, rateLimitWatcher)
265264
if err != nil {
266265
return err
267266
}
268267

269-
internalAPI, err := makeInternalAPI(schema, db, enterprise, rateLimitWatcher)
268+
internalAPI, err := makeInternalAPI(db, logger, schema, enterprise, rateLimitWatcher)
270269
if err != nil {
271270
return err
272271
}
@@ -289,7 +288,7 @@ func Main(enterpriseSetupHook func(database.DB, conftypes.UnifiedWatchable) ente
289288
return nil
290289
}
291290

292-
func makeExternalAPI(db database.DB, schema *graphql.Schema, enterprise enterprise.Services, rateLimiter graphqlbackend.LimitWatcher) (goroutine.BackgroundRoutine, error) {
291+
func makeExternalAPI(db database.DB, logger sglog.Logger, schema *graphql.Schema, enterprise enterprise.Services, rateLimiter graphqlbackend.LimitWatcher) (goroutine.BackgroundRoutine, error) {
293292
listener, err := httpserver.NewListener(httpAddr)
294293
if err != nil {
295294
return nil, err
@@ -323,13 +322,14 @@ func makeExternalAPI(db database.DB, schema *graphql.Schema, enterprise enterpri
323322
}
324323

325324
server := httpserver.New(listener, httpServer, makeServerOptions()...)
326-
log15.Debug("HTTP running", "on", httpAddr)
325+
logger.Debug("HTTP running", sglog.String("on", httpAddr))
327326
return server, nil
328327
}
329328

330329
func makeInternalAPI(
331-
schema *graphql.Schema,
332330
db database.DB,
331+
logger sglog.Logger,
332+
schema *graphql.Schema,
333333
enterprise enterprise.Services,
334334
rateLimiter graphqlbackend.LimitWatcher,
335335
) (goroutine.BackgroundRoutine, error) {
@@ -361,7 +361,7 @@ func makeInternalAPI(
361361
}
362362

363363
server := httpserver.New(listener, httpServer, makeServerOptions()...)
364-
log15.Debug("HTTP (internal) running", "on", httpAddrInternal)
364+
logger.Debug("HTTP (internal) running", sglog.String("on", httpAddrInternal))
365365
return server, nil
366366
}
367367

enterprise/cmd/frontend/internal/authz/init.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import (
77
"strings"
88
"time"
99

10-
"github.com/inconshreveable/log15"
11-
1210
"github.com/sourcegraph/log"
11+
1312
"github.com/sourcegraph/sourcegraph/cmd/frontend/enterprise"
1413
"github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend"
1514
"github.com/sourcegraph/sourcegraph/cmd/frontend/hooks"
@@ -124,7 +123,7 @@ func Init(
124123

125124
info, err := licensing.GetConfiguredProductLicenseInfo()
126125
if err != nil {
127-
log15.Error("Error reading license key for Sourcegraph subscription.", "err", err)
126+
observationCtx.Logger.Error("Error reading license key for Sourcegraph subscription.", log.Error(err))
128127
return []*graphqlbackend.Alert{{
129128
TypeValue: graphqlbackend.AlertTypeError,
130129
MessageValue: "Error reading Sourcegraph license key. Check the logs for more information, or update the license key in the [**site configuration**](/site-admin/configuration).",
@@ -159,7 +158,7 @@ func Init(
159158
return
160159
}
161160
if err != auth.ErrMustBeSiteAdmin {
162-
log15.Error("Error checking current user is site admin", "err", err)
161+
observationCtx.Logger.Error("Error checking current user is site admin", log.Error(err))
163162
http.Error(w, "Error checking current user is site admin. Site admins may check the logs for more information.", http.StatusInternalServerError)
164163
return
165164
}
@@ -173,7 +172,7 @@ func Init(
173172
// to save that DB lookup in most cases.
174173
info, err := licensing.GetConfiguredProductLicenseInfo()
175174
if err != nil {
176-
log15.Error("Error reading license key for Sourcegraph subscription.", "err", err)
175+
observationCtx.Logger.Error("Error reading license key for Sourcegraph subscription.", log.Error(err))
177176
siteadminOrHandler(func() {
178177
enforcement.WriteSubscriptionErrorResponse(w, http.StatusInternalServerError, "Error reading Sourcegraph license key", "Site admins may check the logs for more information. Update the license key in the [**site configuration**](/site-admin/configuration).")
179178
})

enterprise/cmd/frontend/internal/licensing/init/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func Init(
136136
enterpriseServices.LicenseResolver = resolvers.LicenseResolver{}
137137

138138
goroutine.Go(func() {
139-
licensing.StartMaxUserCount(&usersStore{
139+
licensing.StartMaxUserCount(logger, &usersStore{
140140
db: db,
141141
})
142142
})

enterprise/internal/authz/authz.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"strings"
88
"time"
99

10-
"github.com/inconshreveable/log15"
11-
1210
"github.com/sourcegraph/log"
1311

1412
"github.com/sourcegraph/sourcegraph/enterprise/internal/authz/bitbucketserver"
@@ -124,7 +122,7 @@ func ProvidersFromConfig(
124122
PerforceConnection: c,
125123
})
126124
default:
127-
log15.Error("ProvidersFromConfig", "error", errors.Errorf("unexpected connection type: %T", cfg))
125+
logger.Error("ProvidersFromConfig", log.Error(errors.Errorf("unexpected connection type: %T", cfg)))
128126
continue
129127
}
130128
}

enterprise/internal/licensing/user_count.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77

88
"github.com/gomodule/redigo/redis"
99

10-
"github.com/sourcegraph/sourcegraph/internal/redispool"
10+
"github.com/sourcegraph/log"
1111

12-
"github.com/inconshreveable/log15"
12+
"github.com/sourcegraph/sourcegraph/internal/redispool"
1313
)
1414

1515
var (
@@ -81,20 +81,20 @@ func getMaxUsers(c redis.Conn, key string) (int, string, error) {
8181

8282
// checkMaxUsers runs periodically, and if a license key is in use, updates the
8383
// record of maximum count of user accounts in use.
84-
func checkMaxUsers(ctx context.Context, s UsersStore, signature string) error {
84+
func checkMaxUsers(ctx context.Context, logger log.Logger, s UsersStore, signature string) error {
8585
if signature == "" {
8686
// No license key is in use.
8787
return nil
8888
}
8989

9090
count, err := s.Count(ctx)
9191
if err != nil {
92-
log15.Error("licensing.checkMaxUsers: error getting user count", "error", err)
92+
logger.Error("error getting user count", log.Error(err))
9393
return err
9494
}
9595
err = setMaxUsers(signature, count)
9696
if err != nil {
97-
log15.Error("licensing.checkMaxUsers: error setting new max users", "error", err)
97+
logger.Error("error setting new max users", log.Error(err))
9898
return err
9999
}
100100
return nil
@@ -133,7 +133,7 @@ func ActualUserCountDate(ctx context.Context) (string, error) {
133133
}
134134

135135
// StartMaxUserCount starts checking for a new count of max user accounts periodically.
136-
func StartMaxUserCount(s UsersStore) {
136+
func StartMaxUserCount(logger log.Logger, s UsersStore) {
137137
if started {
138138
panic("already started")
139139
}
@@ -144,10 +144,10 @@ func StartMaxUserCount(s UsersStore) {
144144
for {
145145
_, signature, err := GetConfiguredProductLicenseInfoWithSignature()
146146
if err != nil {
147-
log15.Error("licensing.startMaxUserCount: error getting configured license info")
147+
logger.Error("error getting configured license info", log.Error(err))
148148
} else if signature != "" {
149149
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
150-
_ = checkMaxUsers(ctx, s, signature) // updates global state on its own, can safely ignore return value
150+
_ = checkMaxUsers(ctx, logger, s, signature) // updates global state on its own, can safely ignore return value
151151
cancel()
152152
}
153153
time.Sleep(delay)

0 commit comments

Comments
 (0)