mirror of
https://github.com/kopia/kopia.git
synced 2026-01-25 06:48:48 -05:00
This is mostly mechanical and changes how loggers are instantiated. Logger is now associated with a context, passed around all methods, (most methods had ctx, but had to add it in a few missing places). By default Kopia does not produce any logs, but it can be overridden, either locally for a nested context, by calling ctx = logging.WithLogger(ctx, newLoggerFunc) To override logs globally, call logging.SetDefaultLogger(newLoggerFunc) This refactoring allowed removing dependency from Kopia repo and go-logging library (the CLI still uses it, though). It is now also possible to have all test methods emit logs using t.Logf() so that they show up in failure reports, which should make debugging of test failures suck less.
30 lines
548 B
Go
30 lines
548 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/kopia/kopia/internal/serverapi"
|
|
)
|
|
|
|
var (
|
|
serverStatusCommand = serverCommands.Command("status", "Status of Kopia server")
|
|
)
|
|
|
|
func init() {
|
|
serverStatusCommand.Action(serverAction(runServerStatus))
|
|
}
|
|
|
|
func runServerStatus(ctx context.Context, cli *serverapi.Client) error {
|
|
var status serverapi.SourcesResponse
|
|
if err := cli.Get(ctx, "sources", &status); err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, src := range status.Sources {
|
|
fmt.Printf("%15v %v\n", src.Status, src.Source)
|
|
}
|
|
|
|
return nil
|
|
}
|