diff --git a/Makefile b/Makefile index 7825b02..8763340 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # github.com/vidfamn/OGSGameNotifier # -VERSION="v0.1-$(shell git rev-parse --short HEAD)" +VERSION="v0.1.1-$(shell git rev-parse --short HEAD)" BUILD_TIME=$(shell date +"%Y%m%d.%H%M%S") build: clean diff --git a/README.md b/README.md index 0acaedf..c93b5ac 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,6 @@ On success, binaries will be found in the `bin`-directory. * https://github.com/getlantern/systray * https://github.com/hashicorp/go-memdb * https://github.com/ambelovsky/gosf-socketio -* https://github.com/cenkalti/backoff/v4 # Helpful resources diff --git a/main.go b/main.go index 4bbdec4..ed805c0 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "os" "os/signal" + "runtime" "strconv" "syscall" "time" @@ -54,17 +55,19 @@ func main() { logLevel := flag.String("log-level", "info", "log level: debug, error, warn, info") flag.Parse() - // Checks if TTY is detected, if not logs will be written to LogFile - if fileInfo, _ := os.Stdout.Stat(); (fileInfo.Mode() & os.ModeCharDevice) != 0 { - logrus.SetFormatter(&logrus.TextFormatter{}) - } else { - logrus.SetFormatter(&logrus.JSONFormatter{}) - f, err := os.Create(LogFile) + logrus.SetFormatter(&logrus.TextFormatter{}) + + // Log to file on windows + if runtime.GOOS == "windows" { + f, err := os.OpenFile(LogFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { - logrus.Panic(err) + logrus.WithError(err).Error("could not create logfile") + } else { + defer f.Close() + + logrus.SetFormatter(&logrus.JSONFormatter{}) + logrus.SetOutput(f) } - defer f.Close() - logrus.SetOutput(f) } switch *logLevel {