Skip to content

Commit

Permalink
chore: reduce the amount logged by the caller feature
Browse files Browse the repository at this point in the history
  • Loading branch information
linki committed Jul 29, 2019
1 parent 2a1dbfa commit fa3aa5a
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 fa3aa5a

Please sign in to comment.