From 1195768523066aa3cd50d4ab96853e2e64c60a26 Mon Sep 17 00:00:00 2001 From: Keegan Date: Mon, 11 Jul 2022 16:37:25 +0000 Subject: [PATCH] added log defaults --- .gitignore | 3 ++- build.sh | 1 + internal/pkg/logging/logging.go | 16 +++++++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index c2b190e..6f21f0e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ # binaries bin/* - +*.tar.gz # logs *.log + diff --git a/build.sh b/build.sh index bbb7ec1..968f7ea 100755 --- a/build.sh +++ b/build.sh @@ -5,3 +5,4 @@ env GOOS=linux GOARCH=arm GOARM=7 go build -o bin/tui_linux_arm cmd/tui/main.go env GOOS=linux GOARCH=amd64 go build -o bin/tui_linux_amd64 cmd/tui/main.go env GOOS=linux GOARCH=amd64 go build -o bin/server_linux_amd64 cmd/server/main.go +tar -czf bins.tar.gz bin/reactor_linux_arm bin/tui_linux_amd64 bin/server_linux_amd64 diff --git a/internal/pkg/logging/logging.go b/internal/pkg/logging/logging.go index 51c0f31..b9705ff 100644 --- a/internal/pkg/logging/logging.go +++ b/internal/pkg/logging/logging.go @@ -37,15 +37,17 @@ var debugStart time.Time var debugVerbosity int func init() { - filename := time.Now().Format("01-02T15:04:05") - filename += ".log" - f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0664) - if err != nil { - log.Fatal(err) - } - log.SetOutput(f) debugVerbosity = getVerbosity() debugStart = time.Now() + if debugVerbosity > 0 { + filename := time.Now().Format("01-02T15:04:05") + filename += ".log" + f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0664) + if err != nil { + log.Fatal(err) + } + log.SetOutput(f) + } log.SetFlags(log.Flags() &^ (log.Ldate | log.Ltime)) // turns off date and time so we can set manually }