diff --git a/api/cache/access_control.go b/api/cache/access_control.go index 0e0138bc..dd6f0a58 100644 --- a/api/cache/access_control.go +++ b/api/cache/access_control.go @@ -48,7 +48,7 @@ func (o *AccessControlCache) Get(owner user.ID, key string) bool { result, ok := entry.(bool) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return false } diff --git a/api/cache/accessbox.go b/api/cache/accessbox.go index 7da325cc..d07ecdeb 100644 --- a/api/cache/accessbox.go +++ b/api/cache/accessbox.go @@ -67,7 +67,7 @@ func (o *AccessBoxCache) Get(accessKeyID string) *AccessBoxCacheValue { result, ok := entry.(*AccessBoxCacheValue) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } diff --git a/api/cache/buckets.go b/api/cache/buckets.go index 5efc776d..7bccb8a0 100644 --- a/api/cache/buckets.go +++ b/api/cache/buckets.go @@ -65,7 +65,7 @@ func (o *BucketCache) GetByCID(cnrID cid.ID) *data.BucketInfo { key, ok := entry.(string) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", key))) + zap.String("expected", fmt.Sprintf("%T", key)), logs.TagField(logs.TagDatapath)) return nil } @@ -81,7 +81,7 @@ func (o *BucketCache) get(key string) *data.BucketInfo { result, ok := entry.(*data.BucketInfo) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } diff --git a/api/cache/frostfsid.go b/api/cache/frostfsid.go index 417a7ed1..10f72b76 100644 --- a/api/cache/frostfsid.go +++ b/api/cache/frostfsid.go @@ -69,7 +69,7 @@ func get[T any](c *FrostfsIDCache, key any) *T { result, ok := entry.(*T) if !ok { c.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } diff --git a/api/cache/listsession.go b/api/cache/listsession.go index c8d0b685..7205e231 100644 --- a/api/cache/listsession.go +++ b/api/cache/listsession.go @@ -72,7 +72,7 @@ func (l *ListSessionCache) GetListSession(key ListSessionKey) *data.ListSession result, ok := entry.(*data.ListSession) if !ok { l.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } diff --git a/api/cache/names.go b/api/cache/names.go index 42ce8eb0..bccb3a38 100644 --- a/api/cache/names.go +++ b/api/cache/names.go @@ -50,7 +50,7 @@ func (o *ObjectsNameCache) Get(key string) *oid.Address { result, ok := entry.(oid.Address) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } diff --git a/api/cache/network.go b/api/cache/network.go index 899055e9..7dd2afcc 100644 --- a/api/cache/network.go +++ b/api/cache/network.go @@ -54,7 +54,7 @@ func (c *NetworkCache) GetNetworkInfo() *netmap.NetworkInfo { result, ok := entry.(netmap.NetworkInfo) if !ok { c.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } @@ -74,7 +74,7 @@ func (c *NetworkCache) GetNetmap() *netmap.NetMap { result, ok := entry.(netmap.NetMap) if !ok { c.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } diff --git a/api/cache/objects.go b/api/cache/objects.go index e78f8e75..ec3a17de 100644 --- a/api/cache/objects.go +++ b/api/cache/objects.go @@ -49,7 +49,7 @@ func (o *ObjectsCache) GetObject(address oid.Address) *data.ExtendedObjectInfo { result, ok := entry.(*data.ExtendedObjectInfo) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } diff --git a/api/cache/objectslist.go b/api/cache/objectslist.go index d2bb3364..c02ac4ff 100644 --- a/api/cache/objectslist.go +++ b/api/cache/objectslist.go @@ -77,7 +77,7 @@ func (l *ObjectsListCache) GetVersions(key ObjectsListKey) []*data.NodeVersion { result, ok := entry.([]*data.NodeVersion) if !ok { l.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } @@ -96,7 +96,7 @@ func (l *ObjectsListCache) CleanCacheEntriesContainingObject(objectName string, k, ok := key.(ObjectsListKey) if !ok { l.logger.Warn(logs.InvalidCacheKeyType, zap.String("actual", fmt.Sprintf("%T", key)), - zap.String("expected", fmt.Sprintf("%T", k))) + zap.String("expected", fmt.Sprintf("%T", k)), logs.TagField(logs.TagDatapath)) continue } if cnr.Equals(k.cid) && strings.HasPrefix(objectName, k.prefix) { diff --git a/api/cache/policy.go b/api/cache/policy.go index a4ade12d..9d05843b 100644 --- a/api/cache/policy.go +++ b/api/cache/policy.go @@ -54,7 +54,7 @@ func (o *MorphPolicyCache) Get(key MorphPolicyCacheKey) []*chain.Chain { result, ok := entry.([]*chain.Chain) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } diff --git a/api/cache/system.go b/api/cache/system.go index 0395f58a..4e0ad20c 100644 --- a/api/cache/system.go +++ b/api/cache/system.go @@ -50,7 +50,7 @@ func (o *SystemCache) GetObject(key string) *data.ObjectInfo { result, ok := entry.(*data.ObjectInfo) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } @@ -81,7 +81,7 @@ func (o *SystemCache) GetCORS(key string) *data.CORSConfiguration { result, ok := entry.(*data.CORSConfiguration) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } @@ -97,7 +97,7 @@ func (o *SystemCache) GetLifecycleConfiguration(key string) *data.LifecycleConfi result, ok := entry.(*data.LifecycleConfiguration) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } @@ -113,7 +113,7 @@ func (o *SystemCache) GetSettings(key string) *data.BucketSettings { result, ok := entry.(*data.BucketSettings) if !ok { o.logger.Warn(logs.InvalidCacheEntryType, zap.String("actual", fmt.Sprintf("%T", entry)), - zap.String("expected", fmt.Sprintf("%T", result))) + zap.String("expected", fmt.Sprintf("%T", result)), logs.TagField(logs.TagDatapath)) return nil } diff --git a/api/layer/cache.go b/api/layer/cache.go index be6f6618..1995da9c 100644 --- a/api/layer/cache.go +++ b/api/layer/cache.go @@ -54,7 +54,7 @@ func DefaultCachesConfigs(logger *zap.Logger) *CachesConfig { func NewCache(cfg *CachesConfig) *Cache { return &Cache{ - logger: cfg.Logger.With(logs.TagField(logs.TagDatapath)), + logger: cfg.Logger, listsCache: cache.NewObjectsListCache(cfg.ObjectsList), sessionListCache: cache.NewListSessionCache(cfg.SessionList), objCache: cache.New(cfg.Objects), diff --git a/api/layer/object.go b/api/layer/object.go index d5ab2c20..c6709310 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -558,7 +558,7 @@ type logWrapper struct { } func (l *logWrapper) Printf(format string, args ...interface{}) { - l.log.Info(fmt.Sprintf(format, args...)) + l.log.Info(fmt.Sprintf(format, args...), logs.TagField(logs.TagDatapath)) } func IsSystemHeader(key string) bool { diff --git a/api/middleware/response.go b/api/middleware/response.go index eb2ac725..fded5b33 100644 --- a/api/middleware/response.go +++ b/api/middleware/response.go @@ -311,7 +311,7 @@ func LogSuccessResponse(l *zap.Logger) Func { } ctx := r.Context() - reqLogger := reqLogOrDefault(ctx, l).With(logs.TagField(logs.TagDatapath)) + reqLogger := reqLogOrDefault(ctx, l) reqInfo := GetReqInfo(ctx) fields := make([]zap.Field, 0, 6) @@ -331,7 +331,7 @@ func LogSuccessResponse(l *zap.Logger) Func { fields = append(fields, zap.String("user", reqInfo.User)) } - reqLogger.Info(logs.RequestEnd, fields...) + reqLogger.Info(logs.RequestEnd, append(fields, logs.TagField(logs.TagDatapath))...) }) } } diff --git a/cmd/s3-gw/app.go b/cmd/s3-gw/app.go index 3cc4d192..6323115f 100644 --- a/cmd/s3-gw/app.go +++ b/cmd/s3-gw/app.go @@ -1079,13 +1079,13 @@ func (a *App) initServers(ctx context.Context) { if err != nil { a.unbindServers = append(a.unbindServers, serverInfo) a.metrics.MarkUnhealthy(serverInfo.Address) - a.log.With(logs.TagField(logs.TagApp)).Warn(logs.FailedToAddServer, append(fields, zap.Error(err))...) + a.log.Warn(logs.FailedToAddServer, append(fields, zap.Error(err), logs.TagField(logs.TagApp))...) continue } a.metrics.MarkHealthy(serverInfo.Address) a.servers = append(a.servers, srv) - a.log.With(logs.TagField(logs.TagApp)).Info(logs.AddServer, fields...) + a.log.Info(logs.AddServer, append(fields, logs.TagField(logs.TagApp))...) } if len(a.servers) == 0 { @@ -1262,7 +1262,7 @@ func (a *App) tryReconnect(ctx context.Context, sr *http.Server) bool { a.mu.Lock() defer a.mu.Unlock() - a.log.Info(logs.ServerReconnecting) + a.log.Info(logs.ServerReconnecting, logs.TagField(logs.TagApp)) var failedServers []ServerInfo for _, serverInfo := range a.unbindServers { @@ -1289,7 +1289,7 @@ func (a *App) tryReconnect(ctx context.Context, sr *http.Server) bool { }() a.servers = append(a.servers, srv) - a.log.With(logs.TagField(logs.TagApp)).Info(logs.ServerReconnectedSuccessfully, fields...) + a.log.Info(logs.ServerReconnectedSuccessfully, append(fields, logs.TagField(logs.TagApp))...) } a.unbindServers = failedServers diff --git a/creds/tokens/credentials.go b/creds/tokens/credentials.go index aec89838..1efa291b 100644 --- a/creds/tokens/credentials.go +++ b/creds/tokens/credentials.go @@ -202,7 +202,7 @@ func (c *cred) checkIfCredentialsAreRemoved(ctx context.Context, cnrID cid.ID, a func (c *cred) putBoxToCache(accessKeyID string, val *cache.AccessBoxCacheValue) { if err := c.cache.Put(accessKeyID, val); err != nil { - c.log.Warn(logs.CouldntPutAccessBoxIntoCache, zap.String("accessKeyID", accessKeyID)) + c.log.Warn(logs.CouldntPutAccessBoxIntoCache, zap.String("accessKeyID", accessKeyID), logs.TagField(logs.TagDatapath)) } } diff --git a/internal/frostfs/frostfsid/frostfsid.go b/internal/frostfs/frostfsid/frostfsid.go index 8d61b453..d14f62f0 100644 --- a/internal/frostfs/frostfsid/frostfsid.go +++ b/internal/frostfs/frostfsid/frostfsid.go @@ -86,7 +86,7 @@ func (f *FrostFSID) getSubject(addr util.Uint160) (*client.SubjectExtended, erro } if err = f.cache.PutSubject(addr, subj); err != nil { - f.log.Warn(logs.CouldntCacheSubject, zap.Error(err)) + f.log.Warn(logs.CouldntCacheSubject, zap.Error(err), logs.TagField(logs.TagDatapath)) } return subj, nil @@ -121,7 +121,7 @@ func (f *FrostFSID) getUserKey(namespace, name string) (*keys.PublicKey, error) } if err = f.cache.PutUserKey(namespace, name, userKey); err != nil { - f.log.Warn(logs.CouldntCacheUserKey, zap.Error(err)) + f.log.Warn(logs.CouldntCacheUserKey, zap.Error(err), logs.TagField(logs.TagDatapath)) } return userKey, nil