Refine logging level of some statements

This commit is contained in:
Taras Kushnir
2025-09-12 21:45:05 +03:00
parent 64925cd156
commit 0dd2af6376
9 changed files with 41 additions and 41 deletions

View File

@@ -114,7 +114,7 @@ func (v *Verifier) verifyPuzzleValid(ctx context.Context, payload puzzle.Solutio
propertyID := p.PropertyID()
if p.IsZero() && bytes.Equal(propertyID[:], db.TestPropertyUUID.Bytes[:]) {
plog.DebugContext(ctx, "Verifying test puzzle")
plog.Log(ctx, common.LevelTrace, "Verifying test puzzle")
return p, nil, puzzle.TestPropertyError
}

View File

@@ -93,7 +93,7 @@ func RunPeriodicJob(ctx context.Context, j PeriodicJob) {
running = false
// introduction of jitter is supposed to help in case we have multiple workers to distribute the load
case <-time.After(interval + time.Duration(randv2.Int64N(int64(jitter)))):
slog.Log(ctx, LevelTrace, "Running periodic job once", "interval", interval.String(), "jitter", jitter.String())
slog.DebugContext(ctx, "Running periodic job once", "interval", interval.String(), "jitter", jitter.String())
_ = j.RunOnce(ctx, j.NewParams())
}
}
@@ -110,7 +110,7 @@ func RunPeriodicJobOnce(ctx context.Context, j PeriodicJob, params any) error {
}
}()
slog.Log(ctx, LevelTrace, "Running periodic job once")
slog.DebugContext(ctx, "Running periodic job once")
err := j.RunOnce(ctx, params)
if err != nil {
slog.ErrorContext(ctx, "Periodic job failed", ErrAttr(err))

View File

@@ -206,7 +206,7 @@ func (impl *BusinessStoreImpl) createNewUser(ctx context.Context, email, name st
}
if user != nil {
slog.DebugContext(ctx, "Created user in DB", "email", email, "id", user.ID)
slog.InfoContext(ctx, "Created user in DB", "email", email, "id", user.ID)
// we need to update cache as we just set user as missing when checking for it's existence
cacheKey := userCacheKey(user.ID)
@@ -235,7 +235,7 @@ func (impl *BusinessStoreImpl) CreateNewOrganization(ctx context.Context, name s
}
if org != nil {
slog.DebugContext(ctx, "Created organization in DB", "name", name, "id", org.ID)
slog.InfoContext(ctx, "Created organization in DB", "name", name, "id", org.ID)
cacheKey := orgCacheKey(org.ID)
_ = impl.cache.Set(ctx, cacheKey, org)
@@ -257,21 +257,21 @@ func (impl *BusinessStoreImpl) SoftDeleteUser(ctx context.Context, userID int32)
slog.ErrorContext(ctx, "Failed to soft-delete user", "userID", userID, common.ErrAttr(err))
return err
} else {
slog.DebugContext(ctx, "Soft-deleted user", "userID", userID)
slog.InfoContext(ctx, "Soft-deleted user", "userID", userID)
}
if err := impl.querier.SoftDeleteUserOrganizations(ctx, Int(userID)); err != nil {
slog.ErrorContext(ctx, "Failed to soft-delete user organizations", "userID", userID, common.ErrAttr(err))
return err
} else {
slog.DebugContext(ctx, "Soft-deleted user organizations", "userID", userID)
slog.InfoContext(ctx, "Soft-deleted user organizations", "userID", userID)
}
if err := impl.querier.DeleteUserAPIKeys(ctx, Int(userID)); err != nil {
slog.ErrorContext(ctx, "Failed to delete user API keys", "userID", userID, common.ErrAttr(err))
return err
} else {
slog.DebugContext(ctx, "Deleted user API keys", "userID", userID)
slog.InfoContext(ctx, "Deleted user API keys", "userID", userID)
}
// TODO: Delete user API keys from cache
@@ -679,7 +679,7 @@ func (impl *BusinessStoreImpl) CreateNewProperty(ctx context.Context, params *db
return nil, err
}
slog.DebugContext(ctx, "Created new property", "id", property.ID, "name", params.Name, "org", params.OrgID)
slog.InfoContext(ctx, "Created new property", "id", property.ID, "name", params.Name, "org", params.OrgID)
impl.cacheProperty(ctx, property)
// invalidate org properties in cache as we just created a new property
@@ -699,7 +699,7 @@ func (impl *BusinessStoreImpl) UpdateProperty(ctx context.Context, params *dbgen
return nil, err
}
slog.DebugContext(ctx, "Updated property", "name", params.Name, "propID", params.ID)
slog.InfoContext(ctx, "Updated property", "name", params.Name, "propID", params.ID)
impl.cacheProperty(ctx, property)
// invalidate org properties in cache as we just created a new property
@@ -719,7 +719,7 @@ func (impl *BusinessStoreImpl) SoftDeleteProperty(ctx context.Context, propID in
return err
}
slog.DebugContext(ctx, "Soft-deleted property", "propID", propID)
slog.InfoContext(ctx, "Soft-deleted property", "propID", propID)
// update caches
sitekey := UUIDToSiteKey(property.ExternalID)
@@ -761,7 +761,7 @@ func (impl *BusinessStoreImpl) UpdateOrganization(ctx context.Context, orgID int
return nil, err
}
slog.DebugContext(ctx, "Updated organization", "name", name, "orgID", orgID)
slog.InfoContext(ctx, "Updated organization", "name", name, "orgID", orgID)
cacheKey := orgCacheKey(org.ID)
_ = impl.cache.Set(ctx, cacheKey, org)
@@ -784,7 +784,7 @@ func (impl *BusinessStoreImpl) SoftDeleteOrganization(ctx context.Context, orgID
return err
}
slog.DebugContext(ctx, "Soft-deleted organization", "orgID", orgID)
slog.InfoContext(ctx, "Soft-deleted organization", "orgID", orgID)
// update caches
_ = impl.cache.SetMissing(ctx, orgCacheKey(orgID))
@@ -828,7 +828,7 @@ func (impl *BusinessStoreImpl) InviteUserToOrg(ctx context.Context, orgID int32,
_ = impl.cache.Delete(ctx, userOrgsCacheKey(userID))
_ = impl.cache.Delete(ctx, orgUsersCacheKey(orgID))
slog.DebugContext(ctx, "Added org membership invite", "orgID", orgID, "userID", userID)
slog.InfoContext(ctx, "Added org membership invite", "orgID", orgID, "userID", userID)
return nil
}
@@ -850,7 +850,7 @@ func (impl *BusinessStoreImpl) JoinOrg(ctx context.Context, orgID int32, userID
return err
}
slog.DebugContext(ctx, "Accepted org invite", "orgID", orgID, "userID", userID)
slog.InfoContext(ctx, "Accepted org invite", "orgID", orgID, "userID", userID)
// invalidate relevant caches
_ = impl.cache.Delete(ctx, userOrgsCacheKey(userID))
@@ -876,7 +876,7 @@ func (impl *BusinessStoreImpl) LeaveOrg(ctx context.Context, orgID int32, userID
return err
}
slog.DebugContext(ctx, "Left organization", "orgID", orgID, "userID", userID)
slog.InfoContext(ctx, "Left organization", "orgID", orgID, "userID", userID)
// invalidate relevant caches
_ = impl.cache.Delete(ctx, userOrgsCacheKey(userID))
@@ -900,7 +900,7 @@ func (impl *BusinessStoreImpl) RemoveUserFromOrg(ctx context.Context, orgID int3
return err
}
slog.DebugContext(ctx, "Removed user from org", "orgID", orgID, "userID", userID)
slog.InfoContext(ctx, "Removed user from org", "orgID", orgID, "userID", userID)
// invalidate relevant caches
_ = impl.cache.Delete(ctx, userOrgsCacheKey(userID))
@@ -924,7 +924,7 @@ func (impl *BusinessStoreImpl) updateUserSubscription(ctx context.Context, userI
return err
}
slog.DebugContext(ctx, "Updated user subscription", "userID", userID, "subscriptionID", subscriptionID)
slog.InfoContext(ctx, "Updated user subscription", "userID", userID, "subscriptionID", subscriptionID)
if user != nil {
_ = impl.cache.Set(ctx, userCacheKey(user.ID), user)
@@ -949,7 +949,7 @@ func (impl *BusinessStoreImpl) UpdateUser(ctx context.Context, userID int32, nam
return err
}
slog.DebugContext(ctx, "Updated user", "userID", userID)
slog.InfoContext(ctx, "Updated user", "userID", userID)
if user != nil {
_ = impl.cache.Set(ctx, userCacheKey(user.ID), user)
@@ -998,7 +998,7 @@ func (impl *BusinessStoreImpl) UpdateAPIKey(ctx context.Context, externalID pgty
return err
}
slog.DebugContext(ctx, "Updated API key", "externalID", UUIDToSecret(externalID))
slog.InfoContext(ctx, "Updated API key", "externalID", UUIDToSecret(externalID))
if key != nil {
secret := UUIDToSecret(key.ExternalID)
@@ -1072,7 +1072,7 @@ func (impl *BusinessStoreImpl) DeleteAPIKey(ctx context.Context, userID, keyID i
return err
}
slog.DebugContext(ctx, "Deleted API Key", "keyID", keyID, "userID", userID)
slog.InfoContext(ctx, "Deleted API Key", "keyID", keyID, "userID", userID)
// invalidate keys cache
if key != nil {
@@ -1108,7 +1108,7 @@ func (impl *BusinessStoreImpl) UpdateUserAPIKeysRateLimits(ctx context.Context,
return err
}
slog.DebugContext(ctx, "Updated user API keys rate limit", "userID", userID)
slog.InfoContext(ctx, "Updated user API keys rate limit", "userID", userID)
// invalidate keys cache
_ = impl.cache.Delete(ctx, userAPIKeysCacheKey(userID))
@@ -1410,7 +1410,7 @@ func (impl *BusinessStoreImpl) CreateSystemNotification(ctx context.Context, mes
_ = impl.cache.Set(ctx, cacheKey, n)
}
slog.DebugContext(ctx, "Created system notification", "notifID", n.ID)
slog.InfoContext(ctx, "Created system notification", "notifID", n.ID)
return n, err
}
@@ -1585,7 +1585,7 @@ func (s *BusinessStoreImpl) CreateNotificationTemplate(ctx context.Context, name
return nil, err
}
slog.DebugContext(ctx, "Upserted notification template", "name", name, "hash", hash)
slog.InfoContext(ctx, "Upserted notification template", "name", name, "hash", hash)
return t, nil
}
@@ -1649,7 +1649,7 @@ func (s *BusinessStoreImpl) CreateUserNotification(ctx context.Context, n *commo
return nil, err
}
rlog.DebugContext(ctx, "Created user notification", "notifID", notif.ID)
rlog.InfoContext(ctx, "Created user notification", "notifID", notif.ID)
return notif, nil
}
@@ -1698,7 +1698,7 @@ func (s *BusinessStoreImpl) MarkUserNotificationsAttempted(ctx context.Context,
return err
}
slog.DebugContext(ctx, "Updated attempted user notifications", "count", len(ids))
slog.InfoContext(ctx, "Updated attempted user notifications", "count", len(ids))
return nil
}
@@ -1720,7 +1720,7 @@ func (s *BusinessStoreImpl) MarkUserNotificationsProcessed(ctx context.Context,
return err
}
slog.DebugContext(ctx, "Updated processed user notifications", "count", len(ids), "processed_at", t)
slog.InfoContext(ctx, "Updated processed user notifications", "count", len(ids), "processed_at", t)
return nil
}
@@ -1738,7 +1738,7 @@ func (s *BusinessStoreImpl) DeleteUnusedNotificationTemplates(ctx context.Contex
return err
}
slog.DebugContext(ctx, "Deleted unused notification templates", "delivered_before", processedBefore, "updated_before", updatedBefore)
slog.InfoContext(ctx, "Deleted unused notification templates", "delivered_before", processedBefore, "updated_before", updatedBefore)
return nil
}
@@ -1753,7 +1753,7 @@ func (s *BusinessStoreImpl) DeleteSentUserNotifications(ctx context.Context, bef
return err
}
slog.DebugContext(ctx, "Deleted sent user notifications", "before", before)
slog.InfoContext(ctx, "Deleted sent user notifications", "before", before)
return nil
}
@@ -1768,7 +1768,7 @@ func (s *BusinessStoreImpl) DeleteUnsentUserNotifications(ctx context.Context, b
return err
}
slog.DebugContext(ctx, "Deleted UNsent user notifications", "before", before)
slog.InfoContext(ctx, "Deleted UNsent user notifications", "before", before)
return nil
}
@@ -1786,7 +1786,7 @@ func (s *BusinessStoreImpl) DeletePendingUserNotification(ctx context.Context, u
return err
}
slog.DebugContext(ctx, "Deleted pending user notification", "userID", userID, "refID", referenceID)
slog.InfoContext(ctx, "Deleted pending user notification", "userID", userID, "refID", referenceID)
return nil
}
@@ -1842,7 +1842,7 @@ func (s *BusinessStoreImpl) ExpireInternalTrials(ctx context.Context, from, to t
// NOTE: we don't update caches in this case
slog.DebugContext(ctx, "Expired internal trials", "from", from, "to", to)
slog.InfoContext(ctx, "Expired internal trials", "from", from, "to", to)
return nil
}

View File

@@ -47,7 +47,7 @@ func (tracer *myQueryTracer) TraceQueryEnd(ctx context.Context, conn *pgx.Conn,
if !ok {
t = time.Now()
}
slog.DebugContext(ctx, "SQL command finished", "source", "postgres", "duration", time.Since(t).Milliseconds())
slog.Log(ctx, common.LevelTrace, "SQL command finished", "source", "postgres", "duration", time.Since(t).Milliseconds())
}
}

View File

@@ -144,7 +144,7 @@ func (ts *TimeSeriesDB) WriteAccessLogBatch(ctx context.Context, records []*comm
err = scope.Commit()
if err == nil {
slog.DebugContext(ctx, "Inserted batch of access records", "size", len(records))
slog.InfoContext(ctx, "Inserted batch of access records", "size", len(records))
} else {
slog.ErrorContext(ctx, "Failed to insert access log batch", common.ErrAttr(err))
}
@@ -184,7 +184,7 @@ func (ts *TimeSeriesDB) WriteVerifyLogBatch(ctx context.Context, records []*comm
err = scope.Commit()
if err == nil {
slog.DebugContext(ctx, "Inserted batch of verify records", "size", len(records))
slog.InfoContext(ctx, "Inserted batch of verify records", "size", len(records))
} else {
slog.ErrorContext(ctx, "Failed to insert verify log batch", common.ErrAttr(err))
}
@@ -398,7 +398,7 @@ func (ts *TimeSeriesDB) lightDelete(ctx context.Context, tables []string, column
slog.ErrorContext(ctx, "Failed to delete data", "table", table, "column", column, common.ErrAttr(err))
return err
}
slog.DebugContext(ctx, "Deleted data in ClickHouse", "column", column, "table", table)
slog.InfoContext(ctx, "Deleted data in ClickHouse", "column", column, "table", table)
}
return nil

View File

@@ -128,7 +128,7 @@ func (j *jobs) handlePeriodicJob(w http.ResponseWriter, r *http.Request) {
}
ctx := r.Context()
slog.DebugContext(ctx, "Handling on-demand periodic job launch", "job", jobName)
slog.InfoContext(ctx, "Handling on-demand periodic job launch", "job", jobName)
found := false
for _, job := range j.periodicJobs {
@@ -168,7 +168,7 @@ func (j *jobs) handleOneoffJob(w http.ResponseWriter, r *http.Request) {
}
ctx := r.Context()
slog.DebugContext(ctx, "Handling on-demand one-off job launch", "job", jobName)
slog.InfoContext(ctx, "Handling on-demand one-off job launch", "job", jobName)
found := false
for _, job := range j.oneOffJobs {

View File

@@ -38,7 +38,7 @@ func (s *Server) dismissNotification(w http.ResponseWriter, r *http.Request) {
if derr := sess.Delete(session.KeyNotificationID); derr != nil {
slog.ErrorContext(ctx, "Failed to dismiss notification", "id", id, common.ErrAttr(derr))
} else {
slog.DebugContext(ctx, "Dismissed notification", "id", id)
slog.InfoContext(ctx, "Dismissed notification", "id", id)
}
w.WriteHeader(http.StatusOK)
} else {

View File

@@ -805,7 +805,7 @@ func (s *Server) putProperty(w http.ResponseWriter, r *http.Request) (Model, str
if updatedProperty, err := s.Store.Impl().UpdateProperty(ctx, params); err != nil {
renderCtx.ErrorMessage = "Failed to update settings. Please try again."
} else {
slog.DebugContext(ctx, "Edited property", "propID", property.ID, "orgID", org.ID)
slog.InfoContext(ctx, "Edited property", "propID", property.ID, "orgID", org.ID)
renderCtx.SuccessMessage = "Settings were updated"
renderCtx.Property = propertyToUserProperty(updatedProperty)
}

View File

@@ -623,7 +623,7 @@ func (s *Server) createUsageSettingsModel(ctx context.Context, user *dbgen.User)
}
}
} else {
slog.DebugContext(ctx, "User does not have a subscription (usage tab)", "userID", user.ID)
slog.DebugContext(ctx, "User does not have a subscription", "tab", "usage", "userID", user.ID)
renderCtx.WarningMessage = "You don't have an active subscription."
}