Skip to content
Snippets Groups Projects
Commit d82dc9a9 authored by Cornel Rautenbach's avatar Cornel Rautenbach
Browse files

Log changes

parent ce706575
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
"runtime"
"strings" "strings"
"github.com/MindscapeHQ/raygun4go" "github.com/MindscapeHQ/raygun4go"
...@@ -23,8 +24,7 @@ var build string ...@@ -23,8 +24,7 @@ var build string
var raygunClient *raygun4go.Client var raygunClient *raygun4go.Client
// TODO // TODO
// 1. SET JSON vs Console formatting // Sensitive word filtering
// 2. Sensitive word filtering
func InitLogs(requestID *string, isDebugBuild bool, buildVersion string, request *events.APIGatewayProxyRequest, client *raygun4go.Client) { func InitLogs(requestID *string, isDebugBuild bool, buildVersion string, request *events.APIGatewayProxyRequest, client *raygun4go.Client) {
currentRequestID = requestID currentRequestID = requestID
...@@ -33,8 +33,25 @@ func InitLogs(requestID *string, isDebugBuild bool, buildVersion string, request ...@@ -33,8 +33,25 @@ func InitLogs(requestID *string, isDebugBuild bool, buildVersion string, request
build = buildVersion build = buildVersion
raygunClient = client raygunClient = client
formatter := log.JSONFormatter{} if isDebugBuild {
log.SetFormatter(&formatter) log.SetReportCaller(true)
log.SetFormatter(&log.TextFormatter{
ForceColors: true,
PadLevelText: true,
DisableTimestamp: true,
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
// Exclude the caller, will rather be added as a field
return "", ""
},
})
} else {
log.SetReportCaller(true)
log.SetFormatter(&log.JSONFormatter{
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
// Exclude the caller, will rather be added as a field
return "", ""
}})
}
log.SetLevel(LogLevel()) log.SetLevel(LogLevel())
val, exists := os.LookupEnv("DEBUGGING") val, exists := os.LookupEnv("DEBUGGING")
...@@ -49,7 +66,7 @@ func InitLogs(requestID *string, isDebugBuild bool, buildVersion string, request ...@@ -49,7 +66,7 @@ func InitLogs(requestID *string, isDebugBuild bool, buildVersion string, request
if requestID != nil { if requestID != nil {
logger = log.WithFields(log.Fields{ logger = log.WithFields(log.Fields{
"request_id": requestID, "request_id": *requestID,
}) })
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment