ref/lib/apilog: no longer need to log the file:line info in apilog output.
Change-Id: I4f3f76783f8b7c83aa1251e52506178257a0edf2
diff --git a/lib/apilog/apilog.go b/lib/apilog/apilog.go
index 0ab9f7b..c75f8cb 100644
--- a/lib/apilog/apilog.go
+++ b/lib/apilog/apilog.go
@@ -14,10 +14,8 @@
import (
"fmt"
"path"
- "path/filepath"
"reflect"
"runtime"
- "strconv"
"sync/atomic"
"v.io/x/lib/vlog"
@@ -37,14 +35,14 @@
func callerLocation() string {
var funcName string
const stackSkip = 1
- pc, file, line, ok := runtime.Caller(stackSkip + 1)
+ pc, _, _, ok := runtime.Caller(stackSkip + 1)
if ok {
function := runtime.FuncForPC(pc)
if function != nil {
funcName = path.Base(function.Name())
}
}
- return filepath.Base(file) + ":" + strconv.Itoa(line) + " " + funcName
+ return funcName
}
// TODO(cnicolaou): remove LogCall from vlog.
diff --git a/lib/apilog/apilog_test.go b/lib/apilog/apilog_test.go
index 2157fae..7debc4c 100644
--- a/lib/apilog/apilog_test.go
+++ b/lib/apilog/apilog_test.go
@@ -10,7 +10,6 @@
"os"
"path/filepath"
"regexp"
- "strings"
"testing"
"v.io/x/lib/vlog"
@@ -68,14 +67,14 @@
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+\S+ ([^:]*):.*(call|return)\[(\S*) (\S*)`)
+ logCallLineRE := regexp.MustCompile(`\S+ \S+\s+\S+ ([^:]*):.*(call|return)\[(\S*)`)
for _, line := range contents {
match := logCallLineRE.FindStringSubmatch(line)
- if len(match) != 5 {
+ if len(match) != 4 {
t.Errorf("failed to match %s", line)
continue
}
- fileName, callType, location, funcName := match[1], match[2], match[3], match[4]
+ fileName, callType, funcName := match[1], match[2], match[3]
if fileName != "apilog_test.go" {
t.Errorf("unexpected file name: %s", fileName)
continue
@@ -83,9 +82,6 @@
if callType != "call" && callType != "return" {
t.Errorf("unexpected call type: %s", callType)
}
- if !strings.HasPrefix(location, "apilog_test.go:") {
- t.Errorf("unexpected location: %s", location)
- }
if funcName != "apilog_test.myLoggedFunc" {
t.Errorf("unexpected func name: %s", funcName)
}