From 4689797c78d9ef5590776a40cf75eee7b79ba962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 9 Sep 2020 23:48:27 +0200 Subject: [PATCH] Move logging to separate file --- cmd/after-lock/after-lock.go | 14 -------------- cmd/after-lock/logging.go | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 cmd/after-lock/logging.go diff --git a/cmd/after-lock/after-lock.go b/cmd/after-lock/after-lock.go index 710dcde..384229f 100644 --- a/cmd/after-lock/after-lock.go +++ b/cmd/after-lock/after-lock.go @@ -41,20 +41,6 @@ func main() { al.Start() } -func initLogging() *os.File { - if len(logFilePath) == 0 { - return nil - } - - f, err := os.OpenFile(logFilePath, os.O_RDWR | os.O_CREATE | os.O_APPEND, 0600) - if err != nil { - panic(err) - } - - log.SetOutput(f) - return f -} - func handleErrors() { if err := recover(); err != nil { log.Printf("Crashed with unexpected error: %v!\n", err) diff --git a/cmd/after-lock/logging.go b/cmd/after-lock/logging.go new file mode 100644 index 0000000..3ad5e89 --- /dev/null +++ b/cmd/after-lock/logging.go @@ -0,0 +1,20 @@ +package main + +import ( + "os" + "log" +) + +func initLogging() *os.File { + if len(logFilePath) == 0 { + return nil + } + + f, err := os.OpenFile(logFilePath, os.O_RDWR | os.O_CREATE | os.O_APPEND, 0600) + if err != nil { + panic(err) + } + + log.SetOutput(f) + return f +} \ No newline at end of file