Update logging behavior

This commit is contained in:
Tom Wiesing 2022-12-01 12:42:04 +01:00
parent 3b78b06fff
commit 6f1ba24761
No known key found for this signature in database
28 changed files with 176 additions and 137 deletions

View file

@ -2,10 +2,10 @@ package resolver
import (
"context"
"fmt"
"io"
"time"
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
"github.com/FAU-CDI/wisski-distillery/pkg/timex"
)
@ -13,7 +13,7 @@ import (
func (resolver *Resolver) updatePrefixes(ctx context.Context, progress io.Writer) {
go func() {
for t := range timex.TickContext(ctx, resolver.RefreshInterval) {
fmt.Fprintf(progress, "[%s]: reloading prefixes\n", t.Format(time.Stamp))
logging.ProgressF(progress, ctx, "[%s]: reloading prefixes\n", t.Format(time.Stamp))
err := (func() (err error) {
ctx, cancel := context.WithTimeout(ctx, resolver.RefreshInterval)
@ -28,7 +28,7 @@ func (resolver *Resolver) updatePrefixes(ctx context.Context, progress io.Writer
return nil
})()
if err != nil {
fmt.Fprintf(progress, "error reloading prefixes: %s", err.Error())
logging.ProgressF(progress, ctx, "error reloading prefixes: %s", err.Error())
}
}
}()