refactor: Clean up code and change log format (#719)
This commit is contained in:
@ -75,7 +75,7 @@ var (
|
||||
func Get() Store {
|
||||
if !initialized {
|
||||
// This only happens in tests
|
||||
log.Println("[store][Get] Provider requested before it was initialized, automatically initializing")
|
||||
log.Println("[store.Get] Provider requested before it was initialized, automatically initializing")
|
||||
err := Initialize(nil)
|
||||
if err != nil {
|
||||
panic("failed to automatically initialize store: " + err.Error())
|
||||
@ -94,11 +94,11 @@ func Initialize(cfg *storage.Config) error {
|
||||
}
|
||||
if cfg == nil {
|
||||
// This only happens in tests
|
||||
log.Println("[store][Initialize] nil storage config passed as parameter. This should only happen in tests. Defaulting to an empty config.")
|
||||
log.Println("[store.Initialize] nil storage config passed as parameter. This should only happen in tests. Defaulting to an empty config.")
|
||||
cfg = &storage.Config{}
|
||||
}
|
||||
if len(cfg.Path) == 0 && cfg.Type != storage.TypePostgres {
|
||||
log.Printf("[store][Initialize] Creating storage provider of type=%s", cfg.Type)
|
||||
log.Printf("[store.Initialize] Creating storage provider of type=%s", cfg.Type)
|
||||
}
|
||||
ctx, cancelFunc = context.WithCancel(context.Background())
|
||||
switch cfg.Type {
|
||||
@ -120,13 +120,13 @@ func autoSave(ctx context.Context, store Store, interval time.Duration) {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Printf("[store][autoSave] Stopping active job")
|
||||
log.Printf("[store.autoSave] Stopping active job")
|
||||
return
|
||||
case <-time.After(interval):
|
||||
log.Printf("[store][autoSave] Saving")
|
||||
log.Printf("[store.autoSave] Saving")
|
||||
err := store.Save()
|
||||
if err != nil {
|
||||
log.Println("[store][autoSave] Save failed:", err.Error())
|
||||
log.Println("[store.autoSave] Save failed:", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user