Skip to content

Commit

Permalink
enriches caller with package path
Browse files Browse the repository at this point in the history
  • Loading branch information
BugRoger committed Dec 7, 2017
1 parent 30e4be7 commit 28c60eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/cmd/kubernikus/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package kubernikus
import (
"errors"
goflag "flag"
"fmt"
"os"
"os/signal"
"sync"
"syscall"

"github.com/go-kit/kit/log"
"github.com/go-stack/stack"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

Expand Down Expand Up @@ -92,7 +94,7 @@ func (o *Options) Run(c *cobra.Command) error {
var logger log.Logger
logger = log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr))
logger = logutil.NewTrailingNilFilter(logger)
logger = log.With(logger, "ts", log.DefaultTimestampUTC, "caller", log.DefaultCaller)
logger = log.With(logger, "ts", log.DefaultTimestampUTC, "caller", Caller(3))

sigs := make(chan os.Signal, 1)
stop := make(chan struct{})
Expand All @@ -109,3 +111,7 @@ func (o *Options) Run(c *cobra.Command) error {

return nil
}

func Caller(depth int) log.Valuer {
return func() interface{} { return fmt.Sprintf("%+v", stack.Caller(depth)) }
}

0 comments on commit 28c60eb

Please sign in to comment.