lib/apilog: use ctx based logging and sundry bug fixes.
- context.T now wraps rather than embeds logging.Logger
to avoid an annoying go'ism, namely if a struct
with an embedded struct/interface is converted to
an interface then a 'autogenerated' call frame is
inserted in order to create the interface instance. This
messes up the 'InfoDepth' usage.
- logger.Manager needs to test for context.T and extract its
underlying implementation in order to work correctly.
This was the root cause of the bug fixed by: v.io/c/12543
- expand the unit tests to hopefully catch any regressions.
MultiPart: 1/2
Change-Id: I76b1723d31d394be481b4c2947838a1a5096df73
diff --git a/runtime/internal/rpc/test/client_test.go b/runtime/internal/rpc/test/client_test.go
index a42a2a9..bd29251 100644
--- a/runtime/internal/rpc/test/client_test.go
+++ b/runtime/internal/rpc/test/client_test.go
@@ -22,7 +22,9 @@
"v.io/v23/security"
"v.io/v23/vdlroot/signature"
"v.io/v23/verror"
+
"v.io/x/ref"
+ "v.io/x/ref/internal/logger"
_ "v.io/x/ref/runtime/factories/generic"
inaming "v.io/x/ref/runtime/internal/naming"
irpc "v.io/x/ref/runtime/internal/rpc"
@@ -289,6 +291,7 @@
}
emptyCtx := &context.T{}
+ emptyCtx = context.WithLogger(emptyCtx, logger.Global())
_, err := client.StartCall(emptyCtx, "noname", "nomethod", nil)
if verror.ErrorID(err) != verror.ErrBadArg.ID {
t.Fatalf("wrong error: %s", err)
diff --git a/runtime/internal/rt/runtime.go b/runtime/internal/rt/runtime.go
index 6940890..09d1b70 100644
--- a/runtime/internal/rt/runtime.go
+++ b/runtime/internal/rt/runtime.go
@@ -13,6 +13,7 @@
"syscall"
"time"
+ "v.io/x/lib/metadata"
"v.io/x/lib/pubsub"
"v.io/x/lib/vlog"
@@ -112,14 +113,9 @@
// log_dir for the program. It's a hack, but it gets us the metadata
// to device manager-run apps and avoids it for command-lines, which is
// a good enough approximation.
-
- // TODO(caprita): Disabled on 6/11/2015 because changes in the logging
- // system caused this to be always printed. Re-enable in a different
- // way.
-
- // if logger.Manager(ctx).LogDir() != os.TempDir() {
- // ctx.Infof(metadata.ToXML())
- // }
+ if logger.Manager(ctx).LogDir() != os.TempDir() {
+ ctx.Infof(metadata.ToXML())
+ }
// Setup the initial trace.
ctx, err = ivtrace.Init(ctx, flags.Vtrace)