Skip to content

Commit

Permalink
Fix frame and kind logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rmohr committed Jan 11, 2017
1 parent 2f605dc commit fa5d0eb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,18 @@ func (e LogError) Error() string {
}

func (l FilteredLogger) Msg(msg interface{}) {
l.Log("msg", msg)
l.log(2, "msg", msg)
}

func (l FilteredLogger) Msgf(msg string, args ...interface{}) {
l.Msg(fmt.Sprintf(msg, args...))
l.log(2, "msg", fmt.Sprintf(msg, args...))
}

func (l FilteredLogger) Log(params ...interface{}) error {
return l.log(2, params...)
}

func (l FilteredLogger) log(skipFrames int, params ...interface{}) error {
// messages should be logged if any of these conditions are met:
// The log filtering level is debug
// The log filtering level is info and verbosity checks match
Expand All @@ -125,7 +129,7 @@ func (l FilteredLogger) Log(params ...interface{}) error {

logParams = append(logParams, "component", l.component, "level", logLevelNames[l.currentLogLevel])
if l.currentVerbosityLevel > 1 {
_, fileName, lineNumber, _ := runtime.Caller(1)
_, fileName, lineNumber, _ := runtime.Caller(skipFrames)
logParams = append(logParams, "filename", filepath.Base(fileName))
logParams = append(logParams, "line", lineNumber)
}
Expand All @@ -138,7 +142,7 @@ func (l FilteredLogger) Object(obj LoggableObject) *FilteredLogger {

name := obj.GetObjectMeta().GetName()
uid := obj.GetObjectMeta().GetUID()
kind := obj.GetObjectKind()
kind := obj.GetObjectKind().GroupVersionKind().Kind

logParams := make([]interface{}, 0)
logParams = append(logParams, "name", name)
Expand Down

0 comments on commit fa5d0eb

Please sign in to comment.