Skip to content

Commit

Permalink
Merge pull request #133 from linki/tame-logger
Browse files Browse the repository at this point in the history
Reduce the amount logged by the caller feature
  • Loading branch information
linki authored Jul 29, 2019
2 parents 2a1dbfa + fa3aa5a commit 5fc7b8c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"net/http"
"os"
"os/signal"
"path"
"regexp"
"runtime"
"syscall"
"time"

Expand Down Expand Up @@ -83,8 +85,11 @@ func main() {
log.SetLevel(log.DebugLevel)
}

if logFormat == "json" {
log.SetFormatter(&log.JSONFormatter{})
switch logFormat {
case "json":
log.SetFormatter(&log.JSONFormatter{CallerPrettyfier: prettifyCaller})
default:
log.SetFormatter(&log.TextFormatter{CallerPrettyfier: prettifyCaller})
}

log.SetReportCaller(logCaller)
Expand Down Expand Up @@ -270,6 +275,11 @@ func serveMetrics() {
}
}

func prettifyCaller(f *runtime.Frame) (string, string) {
_, filename := path.Split(f.File)
return "", fmt.Sprintf("%s:%d", filename, f.Line)
}

var adminPage = `<html>
<head>
<title>chaoskube</title>
Expand Down

0 comments on commit 5fc7b8c

Please sign in to comment.