mirror of
https://github.com/restic/restic.git
synced 2026-11-22 05:14:23 +00:00
backends: pass error logger to backends
This commit is contained in:
1 parent
13f743e26b
commit
4dc71f24c5
31 files changed
+96
-96
No files matched your search
@@ -55,7 +55,7 @@ const (
|
||||
)
|
||||
|
||||
// Open opens the REST backend with the given config.
|
||||
func Open(_ context.Context, cfg Config, rt http.RoundTripper) (*Backend, error) {
|
||||
func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (*Backend, error) {
|
||||
// use url without trailing slash for layout
|
||||
url := cfg.URL.String()
|
||||
if url[len(url)-1] == '/' {
|
||||
@@ -84,8 +84,8 @@ func drainAndClose(resp *http.Response) error {
|
||||
}
|
||||
|
||||
// Create creates a new REST on server configured in config.
|
||||
func Create(ctx context.Context, cfg Config, rt http.RoundTripper) (*Backend, error) {
|
||||
be, err := Open(ctx, cfg, rt)
|
||||
func Create(ctx context.Context, cfg Config, rt http.RoundTripper, errorLog func(string, ...interface{})) (*Backend, error) {
|
||||
be, err := Open(ctx, cfg, rt, errorLog)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func TestListAPI(t *testing.T) {
|
||||
URL: srvURL,
|
||||
}
|
||||
|
||||
be, err := rest.Open(context.TODO(), cfg, http.DefaultTransport)
|
||||
be, err := rest.Open(context.TODO(), cfg, http.DefaultTransport, t.Logf)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ func runRESTServer(ctx context.Context, t testing.TB, dir, reqListenAddr string)
|
||||
matched = true
|
||||
}
|
||||
}
|
||||
_, _ = fmt.Fprintln(os.Stdout, line) // print all output to console
|
||||
t.Log(line)
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in new issue
Block a user