diff --git a/internal/database/boltdb.go b/internal/database/boltdb.go index c51fb62..9c47728 100644 --- a/internal/database/boltdb.go +++ b/internal/database/boltdb.go @@ -56,7 +56,7 @@ func (b *BoltDBStorage) GetRoute(ctx context.Context, host string) (Route, error r := Route{} err := b.db.One("Hostname", host, &r) if err != nil { - ln.Error(ctx, err, ln.F{"err": err, "action": "route_get_route"}) + ln.Error(ctx, err, ln.Action("get route"), ln.F{"host": host}) switch err { case storm.ErrNotFound: @@ -92,6 +92,8 @@ func (b *BoltDBStorage) PutRoute(ctx context.Context, domain, creator string) (R } defer b.db.Commit() + ln.Log(ctx, r, ln.Action("new route created in database")) + return r, err } @@ -104,6 +106,8 @@ func (b *BoltDBStorage) DeleteRoute(ctx context.Context, id string) error { } defer b.db.Commit() + ln.Log(ctx, r, ln.Action("route deleted from database")) + return b.db.DeleteStruct(&r) } @@ -156,6 +160,8 @@ func (b *BoltDBStorage) PutToken(ctx context.Context, token, owner string, scope } defer b.db.Commit() + ln.Log(ctx, t, ln.Action("new token put into database")) + return t, nil } @@ -167,6 +173,8 @@ func (b *BoltDBStorage) DeleteToken(ctx context.Context, id string) error { return err } + ln.Log(ctx, t, ln.Action("token deleted from database")) + return b.db.DeleteStruct(&t) } @@ -182,6 +190,8 @@ func (b *BoltDBStorage) DeactivateToken(ctx context.Context, id string) error { t.Active = false + ln.Log(ctx, t, ln.Action("token deactivated")) + return b.db.Save(&t) } @@ -227,11 +237,13 @@ func (b *BoltDBStorage) PutCert(ctx context.Context, key string, data []byte) er defer b.db.Commit() + ln.Log(ctx, ln.Action("certificate saved to database"), ln.F{"domain": key}) + return b.db.Save(&cc) } // DeleteCert removes a certificate from the database. -func (b *BoltDBStorage) DeleteCert(ct context.Context, key string) error { +func (b *BoltDBStorage) DeleteCert(ctx context.Context, key string) error { cc := CachedCert{} err := b.db.One("Key", key, &cc) if err != nil { @@ -240,6 +252,8 @@ func (b *BoltDBStorage) DeleteCert(ct context.Context, key string) error { defer b.db.Commit() + ln.Log(ctx, ln.F{"domain": key}, ln.Action("certificate deleted from database")) + return b.db.DeleteStruct(&cc) }