From bfc5c8dd7f1a18099737bc9d087d38c9039a13c4 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 16 Aug 2016 11:41:21 +0100 Subject: [PATCH] Add LOG_DIR env var --- src/github.com/matrix-org/go-neb/goneb.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/github.com/matrix-org/go-neb/goneb.go b/src/github.com/matrix-org/go-neb/goneb.go index 9a93067..607ad42 100644 --- a/src/github.com/matrix-org/go-neb/goneb.go +++ b/src/github.com/matrix-org/go-neb/goneb.go @@ -2,6 +2,7 @@ package main import ( log "github.com/Sirupsen/logrus" + "github.com/matrix-org/dugong" "github.com/matrix-org/go-neb/clients" "github.com/matrix-org/go-neb/database" _ "github.com/matrix-org/go-neb/realms/github" @@ -15,6 +16,7 @@ import ( "net/http" _ "net/http/pprof" "os" + "path/filepath" ) func main() { @@ -22,6 +24,20 @@ func main() { databaseType := os.Getenv("DATABASE_TYPE") databaseURL := os.Getenv("DATABASE_URL") baseURL := os.Getenv("BASE_URL") + logDir := os.Getenv("LOG_DIR") + + if logDir != "" { + log.AddHook(dugong.NewFSHook( + filepath.Join(logDir, "info.log"), + filepath.Join(logDir, "warn.log"), + filepath.Join(logDir, "error.log"), + )) + } + + log.Infof( + "Go-NEB (BIND_ADDRESS=%s DATABASE_TYPE=%s DATABASE_URL=%s BASE_URL=%s LOG_DIR=%s)", + bindAddress, databaseType, databaseURL, baseURL, logDir, + ) err := types.BaseURL(baseURL) if err != nil {