Skip to content

Commit df12b2d

Browse files
committed
Add more debug logs
1 parent 842d55d commit df12b2d

4 files changed

Lines changed: 47 additions & 2 deletions

File tree

pkg/middleware/middleware.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,34 @@ func NewHTTPCacheHandler(c configurationtypes.AbstractConfigurationInterface) *S
9797
storers := []types.Storer{}
9898
if len(storedStorers) != 0 {
9999
dc := c.GetDefaultCache()
100+
c.GetLogger().Warn("Initializing storers with configuration", zap.Any("redis", dc.GetRedis()), zap.Any("storers", dc.GetStorers()))
101+
c.GetLogger().Warn("Redis configuration details",
102+
zap.String("url", dc.GetRedis().URL),
103+
zap.String("uuid", dc.GetRedis().Uuid))
104+
100105
for _, s := range []string{dc.GetBadger().Uuid, dc.GetEtcd().Uuid, dc.GetNats().Uuid, dc.GetNuts().Uuid, dc.GetOlric().Uuid, dc.GetOtter().Uuid, dc.GetRedis().Uuid, dc.GetSimpleFS().Uuid} {
101106
if s != "" {
107+
c.GetLogger().Warn("Attempting to get storer with UUID", zap.String("uuid", s))
102108
if st := core.GetRegisteredStorer(s); st != nil {
103109
storers = append(storers, st.(types.Storer))
110+
c.GetLogger().Warn("Successfully registered storer",
111+
zap.String("name", st.(types.Storer).Name()),
112+
zap.String("uuid", st.(types.Storer).Uuid()))
113+
} else {
114+
c.GetLogger().Warn("Failed to get storer with UUID", zap.String("uuid", s))
104115
}
105116
}
106117
}
107118

108119
storers = reorderStorers(storers, c.GetDefaultCache().GetStorers())
120+
c.GetLogger().Warn("Storers after reordering", zap.Any("storers", storers))
109121

110122
if len(storers) > 0 {
111123
names := []string{}
112124
for _, storer := range storers {
113125
names = append(names, storer.Name())
114126
}
115-
c.GetLogger().Debugf("You're running Souin with the following storages in this order %s", strings.Join(names, ", "))
127+
c.GetLogger().Warn("Running Souin with storages", zap.Strings("storages", names))
116128
}
117129
}
118130
if len(storers) == 0 {
@@ -121,7 +133,13 @@ func NewHTTPCacheHandler(c configurationtypes.AbstractConfigurationInterface) *S
121133
memoryStorer, _ := storage.Factory(c)
122134
if st := core.GetRegisteredStorer(types.DefaultStorageName + "-"); st != nil {
123135
memoryStorer = st.(types.Storer)
136+
c.GetLogger().Warn("Using existing default storer",
137+
zap.String("name", memoryStorer.Name()),
138+
zap.String("uuid", memoryStorer.Uuid()))
124139
} else {
140+
c.GetLogger().Warn("Registering new default storer",
141+
zap.String("name", memoryStorer.Name()),
142+
zap.String("uuid", memoryStorer.Uuid()))
125143
core.RegisterStorage(memoryStorer)
126144
}
127145
storers = append(storers, memoryStorer)

plugins/caddy/dispatch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ func (s *SouinCaddyMiddleware) parseStorages(ctx caddy.Context) {
172172
s.Configuration.DefaultCache.GetStale(),
173173
)
174174
}
175+
} else {
176+
// Log Found false
177+
s.logger.Warn("Redis storage not found")
175178
}
176179
if s.Configuration.DefaultCache.SimpleFS.Found {
177180
e := dispatchStorage(ctx, "simplefs", s.Configuration.DefaultCache.SimpleFS, s.Configuration.DefaultCache.GetStale())

plugins/caddy/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/darkweak/souin/plugins/caddy
1+
module github.com/popcorn/souin/plugins/caddy
22

33
go 1.22.3
44

plugins/caddy/httpcache.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/darkweak/souin/pkg/middleware"
1515
surrogates_providers "github.com/darkweak/souin/pkg/surrogate/providers"
1616
"github.com/darkweak/storages/core"
17+
"go.uber.org/zap"
1718
)
1819

1920
const moduleName = "cache"
@@ -242,7 +243,26 @@ func dispatchStorage(ctx caddy.Context, name string, provider configurationtypes
242243
},
243244
Stale: stale,
244245
})
246+
247+
ctx.Logger().Warn("Attempting to load storage module",
248+
zap.String("name", name),
249+
zap.String("config", string(b)),
250+
zap.String("url", provider.URL),
251+
zap.String("path", provider.Path))
252+
245253
_, e := ctx.LoadModuleByID("storages.cache."+name, b)
254+
if e != nil {
255+
ctx.Logger().Error("Failed to load storage module",
256+
zap.String("name", name),
257+
zap.Error(e),
258+
zap.String("url", provider.URL),
259+
zap.String("path", provider.Path))
260+
} else {
261+
ctx.Logger().Warn("Successfully loaded storage module",
262+
zap.String("name", name),
263+
zap.String("url", provider.URL),
264+
zap.String("path", provider.Path))
265+
}
246266

247267
return e
248268
}
@@ -263,6 +283,10 @@ func (s *SouinCaddyMiddleware) Provision(ctx caddy.Context) error {
263283
return err
264284
}
265285

286+
// Log the complete configuration
287+
configJSON, _ := json.MarshalIndent(s.Configuration, "", " ")
288+
s.logger.Warn("Complete Souin Configuration:", zap.String("config", string(configJSON)))
289+
266290
s.parseStorages(ctx)
267291

268292
bh := middleware.NewHTTPCacheHandler(&s.Configuration)

0 commit comments

Comments
 (0)