update tracerx

This commit is contained in:
Rick Olson 2015-05-28 11:41:28 -06:00
parent 1598edab27
commit 80930f63d7
2 changed files with 7 additions and 3 deletions

@ -14,7 +14,7 @@ authors = [
"github.com/kr/pty" = "5cf931ef8f76dccd0910001d74a58a7fca84a83d"
"github.com/kr/text" = "6807e777504f54ad073ecef66747de158294b639"
"github.com/olekukonko/ts" = "ecf753e7c962639ab5a1fb46f7da627d4c0a04b8"
"github.com/rubyist/tracerx" = "f6aa9369b3277bc21384878e8279642da722f407"
"github.com/rubyist/tracerx" = "51cd50e73e07cc41c22caec66af15313dff1aebb"
"github.com/spf13/cobra" = "864687ae689edc28688c67edef47e3d2ad651a1b"
"github.com/spf13/pflag" = "463bdc838f2b35e9307e91d480878bda5fff7232"
"github.com/technoweenie/assert" = "b25ea301d127043ffacf3b2545726e79b6632139"

@ -68,7 +68,7 @@ func PerformanceSince(what string, t time.Time) {
func PerformanceSinceKey(key, what string, t time.Time) {
tracer := getTracer(key)
if tracer.enabled && tracer.performance {
if tracer.performance {
since := time.Since(t)
fmt.Fprintf(tracer.w, "performance %s: %.9f s\n", what, since.Seconds())
}
@ -114,7 +114,7 @@ func initializeTracer(key string) *tracer {
trace := os.Getenv(fmt.Sprintf("%s_TRACE", key))
if trace == "" || strings.ToLower(trace) == "false" {
return tracer
tracer.enabled = false
}
perf := os.Getenv(fmt.Sprintf("%s_TRACE_PERFORMANCE", key))
@ -122,6 +122,10 @@ func initializeTracer(key string) *tracer {
tracer.performance = true
}
if !tracer.enabled && !tracer.performance {
return tracer
}
fd, err := strconv.Atoi(trace)
if err != nil {
// Not a number, it could be a path for a log file