x.ref/runtime: convert to context-based logging.
MultiPart: 1/2
Change-Id: Ia337148d3e5958c3f2b9e614f22ad0a90fbedace
diff --git a/runtime/factories/chrome/chrome.go b/runtime/factories/chrome/chrome.go
index 5108bbe..8245a77 100644
--- a/runtime/factories/chrome/chrome.go
+++ b/runtime/factories/chrome/chrome.go
@@ -12,7 +12,6 @@
"v.io/v23"
"v.io/v23/context"
"v.io/v23/rpc"
- "v.io/x/lib/vlog"
"v.io/x/ref/lib/flags"
"v.io/x/ref/runtime/internal"
@@ -41,6 +40,6 @@
if err != nil {
return nil, nil, shutdown, err
}
- vlog.Log.VI(1).Infof("Initializing chrome RuntimeFactory.")
+ ctx.VI(1).Infof("Initializing chrome RuntimeFactory.")
return runtime, ctx, shutdown, nil
}
diff --git a/runtime/factories/fake/runtime.go b/runtime/factories/fake/runtime.go
index 2282a47..b5ea1e9 100644
--- a/runtime/factories/fake/runtime.go
+++ b/runtime/factories/fake/runtime.go
@@ -10,6 +10,7 @@
"v.io/v23/namespace"
"v.io/v23/rpc"
"v.io/v23/security"
+ "v.io/x/ref/internal/logger"
"v.io/x/ref/lib/apilog"
vsecurity "v.io/x/ref/lib/security"
tnaming "v.io/x/ref/runtime/internal/testing/mocks/naming"
@@ -38,8 +39,8 @@
}
func (r *Runtime) Init(ctx *context.T) error {
- defer apilog.LogCall(ctx)(ctx) // gologcop: DO NOT EDIT, MUST BE FIRST STATEMENT
- return nil
+ // nologcall
+ return logger.Manager(ctx).ConfigureFromFlags()
}
func (r *Runtime) WithPrincipal(ctx *context.T, principal security.Principal) (*context.T, error) {
diff --git a/runtime/factories/gce/gce.go b/runtime/factories/gce/gce.go
index b38548b..a0d25e8 100644
--- a/runtime/factories/gce/gce.go
+++ b/runtime/factories/gce/gce.go
@@ -16,7 +16,6 @@
"v.io/v23"
"v.io/v23/context"
"v.io/v23/rpc"
- "v.io/x/lib/vlog"
"v.io/x/lib/netstate"
"v.io/x/ref/lib/flags"
@@ -68,7 +67,7 @@
return nil, nil, shutdown, err
}
- vlog.Log.VI(1).Infof("Initializing GCE RuntimeFactory.")
+ ctx.VI(1).Infof("Initializing GCE RuntimeFactory.")
runtimeFactoryShutdown := func() {
ac.Shutdown()
diff --git a/runtime/factories/generic/generic.go b/runtime/factories/generic/generic.go
index eabda93..54e4149 100644
--- a/runtime/factories/generic/generic.go
+++ b/runtime/factories/generic/generic.go
@@ -12,7 +12,6 @@
"v.io/v23"
"v.io/v23/context"
"v.io/v23/rpc"
- "v.io/x/lib/vlog"
"v.io/x/ref/lib/flags"
"v.io/x/ref/runtime/internal"
@@ -58,7 +57,7 @@
if err != nil {
return nil, nil, nil, err
}
- vlog.Log.VI(1).Infof("Initializing generic RuntimeFactory.")
+ ctx.VI(1).Infof("Initializing generic RuntimeFactory.")
runtimeFactoryShutdown := func() {
ac.Shutdown()
diff --git a/runtime/factories/roaming/roaming.go b/runtime/factories/roaming/roaming.go
index 5424691..9dd781e 100644
--- a/runtime/factories/roaming/roaming.go
+++ b/runtime/factories/roaming/roaming.go
@@ -20,7 +20,6 @@
"v.io/x/lib/netconfig"
"v.io/x/lib/netstate"
"v.io/x/lib/pubsub"
- "v.io/x/lib/vlog"
"v.io/v23"
"v.io/v23/context"
@@ -157,29 +156,29 @@
netstate.InvalidateCache()
cur, err := netstate.GetAccessibleIPs()
if err != nil {
- vlog.Errorf("failed to read network state: %s", err)
+ ctx.Errorf("failed to read network state: %s", err)
continue
}
removed := netstate.FindRemoved(prev, cur)
added := netstate.FindAdded(prev, cur)
- vlog.VI(2).Infof("Previous: %d: %s", len(prev), prev)
- vlog.VI(2).Infof("Current : %d: %s", len(cur), cur)
- vlog.VI(2).Infof("Added : %d: %s", len(added), added)
- vlog.VI(2).Infof("Removed : %d: %s", len(removed), removed)
+ ctx.VI(2).Infof("Previous: %d: %s", len(prev), prev)
+ ctx.VI(2).Infof("Current : %d: %s", len(cur), cur)
+ ctx.VI(2).Infof("Added : %d: %s", len(added), added)
+ ctx.VI(2).Infof("Removed : %d: %s", len(removed), removed)
if len(removed) == 0 && len(added) == 0 {
- vlog.VI(2).Infof("Network event that lead to no address changes since our last 'baseline'")
+ ctx.VI(2).Infof("Network event that lead to no address changes since our last 'baseline'")
continue
}
if len(removed) > 0 {
- vlog.VI(2).Infof("Sending removed: %s", removed)
+ ctx.VI(2).Infof("Sending removed: %s", removed)
ch <- irpc.NewRmAddrsSetting(removed.AsNetAddrs())
}
// We will always send the best currently available address
if chosen, err := listenSpec.AddressChooser.ChooseAddress(listenSpec.Addrs[0].Protocol, cur.AsNetAddrs()); err == nil && chosen != nil {
- vlog.VI(2).Infof("Sending added and chosen: %s", chosen)
+ ctx.VI(2).Infof("Sending added and chosen: %s", chosen)
ch <- irpc.NewAddAddrsSetting(chosen)
} else {
- vlog.VI(2).Infof("Ignoring added %s", added)
+ ctx.VI(2).Infof("Ignoring added %s", added)
}
prev = cur
case <-cleanup:
diff --git a/runtime/factories/roaming/roaming_server.go b/runtime/factories/roaming/roaming_server.go
index 10e801a..c87d37a 100644
--- a/runtime/factories/roaming/roaming_server.go
+++ b/runtime/factories/roaming/roaming_server.go
@@ -8,12 +8,9 @@
import (
"fmt"
- "log"
"v.io/v23"
"v.io/v23/rpc"
- "v.io/x/lib/vlog"
-
"v.io/x/ref/lib/xrpc"
_ "v.io/x/ref/runtime/factories/roaming"
)
@@ -24,7 +21,7 @@
server, err := xrpc.NewServer(ctx, "roamer", &dummy{}, nil)
if err != nil {
- vlog.Fatalf("unexpected error: %q", err)
+ ctx.Fatalf("unexpected error: %q", err)
}
watcher := make(chan rpc.NetworkChange, 1)
server.WatchNetwork(watcher)