Skip to content

Commit 992e91c

Browse files
committed
feat(npm): adjust log levels
1 parent 1133462 commit 992e91c

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

mirror/npm/npm.go

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ type NpmService struct {
6161
func (ns *NpmService) Init(app *goapp.App) (err error) {
6262
ns.Logger.Info("Init")
6363

64-
ns.Logger.WithFields(log.Fields{
65-
"basePath": ns.Config.Path,
66-
"name": ns.Config.Code,
67-
}).Info("Init bolt db")
68-
6964
return ns.openDatabase()
7065
}
7166

@@ -110,7 +105,7 @@ func (ns *NpmService) Serve(state *goapp.GoroutineState) error {
110105
iteration := 0
111106

112107
sync := func() {
113-
ns.Logger.Info("Starting a new sync...")
108+
ns.Logger.Debug("Starting a new sync...")
114109

115110
ns.SyncPackages()
116111

@@ -178,7 +173,7 @@ func (ns *NpmService) Serve(state *goapp.GoroutineState) error {
178173
Status: pkgmirror.STATUS_HOLD,
179174
}
180175

181-
ns.Logger.Info("Wait before starting a new sync...")
176+
ns.Logger.Debug("Wait before starting a new sync...")
182177

183178
// we recursively call sync unless a state.In comes in to exist the current
184179
// go routine (ie, the Serve function). This might not close the sync processus
@@ -201,14 +196,14 @@ func (ns *NpmService) SyncPackages() error {
201196
"action": "SyncPackages",
202197
})
203198

204-
logger.Info("Starting SyncPackages")
199+
logger.Debug("Starting SyncPackages")
205200

206201
ns.StateChan <- pkgmirror.State{
207202
Message: "Fetching packages metadatas",
208203
Status: pkgmirror.STATUS_RUNNING,
209204
}
210205

211-
logger.Info("Wait worker to complete")
206+
logger.Debug("Wait worker to complete")
212207

213208
dm := pkgmirror.NewWorkerManager(10, func(id int, data <-chan interface{}, result chan interface{}) {
214209
for raw := range data {
@@ -294,7 +289,7 @@ func (ns *NpmService) SyncPackages() error {
294289
return nil
295290
})
296291

297-
logger.Info("Wait for download to complete")
292+
logger.Debug("Wait for download to complete")
298293

299294
ns.StateChan <- pkgmirror.State{
300295
Message: "Wait for download to complete",
@@ -320,7 +315,7 @@ func (ns *NpmService) savePackage(pkg *FullPackageDefinition) error {
320315
"package": pkg.Name,
321316
})
322317

323-
logger.Info("Save package information")
318+
logger.Debug("Save package information")
324319

325320
ns.StateChan <- pkgmirror.State{
326321
Message: fmt.Sprintf("Save package information: %s", pkg.Name),
@@ -431,15 +426,15 @@ func (ns *NpmService) Get(key string) ([]byte, error) {
431426
"key": key,
432427
})
433428

434-
logger.Info("Get raw data")
429+
logger.Debug("Get raw data")
435430

436431
err := ns.DB.View(func(tx *bolt.Tx) error {
437432
b := tx.Bucket(ns.Config.Code)
438433

439434
raw := b.Get([]byte(key))
440435

441436
if len(raw) == 0 {
442-
logger.Info("Package does not exist in local DB")
437+
logger.Debug("Package does not exist in local DB")
443438

444439
return pkgmirror.EmptyKeyError
445440
}
@@ -453,7 +448,7 @@ func (ns *NpmService) Get(key string) ([]byte, error) {
453448

454449
// the key is not here, get it from the source
455450
if err == pkgmirror.EmptyKeyError {
456-
logger.Info("Package does not exist")
451+
logger.Debug("Package does not exist")
457452

458453
if err := ns.UpdatePackage(key); err != nil {
459454
return data, err
@@ -502,7 +497,7 @@ func (ns *NpmService) WriteArchive(w io.Writer, pkg, version string) error {
502497
url = fmt.Sprintf("%s/%s/-/%s-%s.tgz", ns.Config.SourceServer, pkg, pkg, version)
503498
}
504499

505-
logger.WithField("url", url).Info("Create vault entry")
500+
logger.WithField("url", url).Debug("Create vault entry")
506501

507502
resp, err := http.Get(url)
508503

@@ -529,7 +524,7 @@ func (ns *NpmService) WriteArchive(w io.Writer, pkg, version string) error {
529524
}
530525
}
531526

532-
logger.Info("Read vault entry")
527+
logger.Debug("Read vault entry")
533528
if _, err := ns.Vault.Get(vaultKey, w); err != nil {
534529
return err
535530
}

0 commit comments

Comments
 (0)