From 4d1162015bb8b078ce6a09b830cfa2cef90d0687 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 18 Dec 2024 18:06:35 -0600 Subject: [PATCH] change: rolls back the (unrelated, unnecessary) logger changes --- logger/logger.go | 35 +++-------------------------------- stmps.go | 4 +--- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/logger/logger.go b/logger/logger.go index 08046df..d5d317b 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -3,53 +3,24 @@ package logger -import ( - "fmt" - "io" - "os" -) +import "fmt" type Logger struct { Prints chan string - fout io.WriteCloser } -func Init(file string) *Logger { - l := Logger{ - Prints: make(chan string, 100), - } - if file != "" { - var err error - l.fout, err = os.Create(file) - if err != nil { - fmt.Printf("error opening requested log file %q\n", file) - } - } - return &l +func Init() *Logger { + return &Logger{make(chan string, 100)} } func (l *Logger) Print(s string) { - if l.fout != nil { - fmt.Fprintf(l.fout, "%s\n", s) - } l.Prints <- s } func (l *Logger) Printf(s string, as ...interface{}) { - if l.fout != nil { - fmt.Fprintf(l.fout, s, as...) - fmt.Fprintf(l.fout, "\n") - } l.Prints <- fmt.Sprintf(s, as...) } func (l *Logger) PrintError(source string, err error) { l.Printf("Error(%s) -> %s", source, err.Error()) } - -func (l *Logger) Close() error { - if l.fout != nil { - return l.fout.Close() - } - return nil -} diff --git a/stmps.go b/stmps.go index 128b3c5..722c63a 100644 --- a/stmps.go +++ b/stmps.go @@ -113,7 +113,6 @@ func main() { memprofile := flag.String("memprofile", "", "write memory profile to `file`") configFile := flag.String("config", "", "use config `file`") version := flag.Bool("version", false, "print the stmps version and exit") - logFile := flag.String("log", "", "also write logs to this file") flag.Parse() if *help { @@ -158,8 +157,7 @@ func main() { osExit(2) } - logger := logger.Init(*logFile) - defer logger.Close() + logger := logger.Init() initCommandHandler(logger) // init mpv engine