Skip to content

Commit

Permalink
trace as bebug
Browse files Browse the repository at this point in the history
  • Loading branch information
mdigger committed Sep 6, 2017
1 parent d0534ff commit b78bdf5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type TraceContext struct {
// err is passed the "error" field is set, and the log level is error.
func (t *TraceContext) Stop(err *error) error {
t.WithField("duration", time.Since(t.started))
level := InfoLevel
level := DebugLevel
if err != nil && *err != nil {
t.WithField("error", (*err).Error())
level = ErrorLevel
Expand All @@ -40,25 +40,25 @@ func (t *TraceContext) WithField(name string, value interface{}) *TraceContext {
func (c *Context) trace(message string) *TraceContext {
return &TraceContext{
Message: message,
context: c.newContext(nil),
context: c.newContext(c.Fields),
started: time.Now(),
}
}

// Trace sends to the log information message and returns a new TraceContext
// Trace sends to the log debug message and returns a new TraceContext
// with a Stop method to fire off a corresponding completion log. Useful with
// defer.
func (c *Context) Trace(message string) *TraceContext {
// do not move to the trace method to operate correctly determining Source
c.print(InfoLevel, message)
// c.print(DebugLevel, message)
return c.trace(message)
}

// Trace sends to the log formatted information message and returns a new
// Tracef sends to the log formatted debug message and returns a new
// TraceContext with a Stop method to fire off a corresponding completion log.
// Useful with defer.
func (c *Context) Tracef(format string, v ...interface{}) *TraceContext {
message := fmt.Sprintf(format, v...)
c.print(InfoLevel, message)
// c.print(DebugLevel, message)
return c.trace(message)
}

0 comments on commit b78bdf5

Please sign in to comment.