Merge "ref/lib/apilog: use vlog 'Depth' methods to print appropriate filenames in log headers."
diff --git a/lib/apilog/apilog.go b/lib/apilog/apilog.go
index 83c11b0..0ab9f7b 100644
--- a/lib/apilog/apilog.go
+++ b/lib/apilog/apilog.go
@@ -6,12 +6,9 @@
 // In particular, logcop will inject calls to these functions as the first
 // statement in methods that implement the v23 API. The output can
 // be controlled by vlog verbosity or vtrace.
-// The log lines generated have a header that refers to this file
-// and the message includes the file and line # of the caller. This is
-// currently the best we can do given the functionality of the underlying
-// vlog package. It has the advantage the api logging can be selectively
-// enabled/disabled globally using --vmodule=apilog=<level>, but the
-// disadvantage that it can't be controlled at the per file level.
+// --vmodule=apilog=<level> can be used to globally control logging,
+// and --vmodule=module=<level> can also be used to control logging
+// on a per-file basis.
 package apilog
 
 import (
@@ -115,7 +112,7 @@
 	} else {
 		output = fmt.Sprintf("call[%s %s]", callerLocation, invocationId)
 	}
-	logger.Info(output)
+	logger.InfoDepth(1, output)
 
 	// TODO(mattr): annotate vtrace span.
 	return func(ctx *context.T, v ...interface{}) {
@@ -125,7 +122,7 @@
 		} else {
 			output = fmt.Sprintf("return[%s %s]", callerLocation, invocationId)
 		}
-		logger.Info(output)
+		logger.InfoDepth(1, output)
 		// TODO(mattr): annotate vtrace span.
 	}
 }
@@ -146,11 +143,11 @@
 	callerLocation := callerLocation()
 	invocationId := newInvocationIdentifier()
 	output := fmt.Sprintf("call[%s %s]: %s", callerLocation, invocationId, fmt.Sprintf(format, v...))
-	logger.Info(output)
+	logger.InfoDepth(1, output)
 	// TODO(mattr): annotate vtrace span.
 	return func(ctx *context.T, format string, v ...interface{}) {
 		output := fmt.Sprintf("return[%s %s]: %v", callerLocation, invocationId, fmt.Sprintf(format, derefSlice(v)...))
-		logger.Info(output)
+		logger.InfoDepth(1, output)
 		// TODO(mattr): annotate vtrace span.
 	}
 }
diff --git a/lib/apilog/apilog_test.go b/lib/apilog/apilog_test.go
index d085efc..2157fae 100644
--- a/lib/apilog/apilog_test.go
+++ b/lib/apilog/apilog_test.go
@@ -68,7 +68,7 @@
 	if want, got := 2, len(contents); want != got {
 		t.Errorf("Expected %d info lines, got %d instead", want, got)
 	}
-	logCallLineRE := regexp.MustCompile(`\S+ \S+ \S+ ([^:]*):.*(call|return)\[(\S*) (\S*)`)
+	logCallLineRE := regexp.MustCompile(`\S+ \S+\s+\S+ ([^:]*):.*(call|return)\[(\S*) (\S*)`)
 	for _, line := range contents {
 		match := logCallLineRE.FindStringSubmatch(line)
 		if len(match) != 5 {
@@ -76,7 +76,7 @@
 			continue
 		}
 		fileName, callType, location, funcName := match[1], match[2], match[3], match[4]
-		if fileName != "apilog.go" {
+		if fileName != "apilog_test.go" {
 			t.Errorf("unexpected file name: %s", fileName)
 			continue
 		}
diff --git a/runtime/internal/rt/runtime.go b/runtime/internal/rt/runtime.go
index 9ebfbef..c5c9374 100644
--- a/runtime/internal/rt/runtime.go
+++ b/runtime/internal/rt/runtime.go
@@ -94,7 +94,7 @@
 	}
 
 	err := vlog.ConfigureLibraryLoggerFromFlags()
-	if err != nil && err != vlog.Configured {
+	if err != nil && err != vlog.ErrConfigured {
 		return nil, nil, nil, err
 	}
 	// We want to print out metadata only into the log files, to avoid