Browse Source
Write log into separate log-file
feature/add-logging
Fabian Vowie
3 years ago
No known key found for this signature in database
GPG Key ID: C27317C33B27C410
2 changed files with
10 additions and
2 deletions
-
.gitignore
-
main.go
|
|
@ -15,4 +15,5 @@ |
|
|
|
go.work |
|
|
|
|
|
|
|
# Lithium specific |
|
|
|
settings.json |
|
|
|
settings.json |
|
|
|
lithium.log |
|
|
@ -148,8 +148,15 @@ func RegisterRoutes(r *mux.Router, pipelines []pipelines.IPipeline, storageProvi |
|
|
|
} |
|
|
|
|
|
|
|
func main() { |
|
|
|
logFile, err := os.OpenFile("lithium.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) |
|
|
|
if err == nil { |
|
|
|
multiWriter := io.MultiWriter(os.Stdout, logFile) |
|
|
|
logrus.SetOutput(multiWriter) |
|
|
|
} else { |
|
|
|
logrus.SetOutput(os.Stdout) |
|
|
|
} |
|
|
|
|
|
|
|
logrus.SetFormatter(&logrus.JSONFormatter{}) |
|
|
|
logrus.SetOutput(os.Stdout) |
|
|
|
|
|
|
|
appSettings, err := settings.LoadSettings(afero.NewOsFs()) |
|
|
|
if err != nil { |
|
|
|