Skip to content

Commit

Permalink
change: rolls back the (unrelated, unnecessary) logger changes
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxserxxx committed Dec 19, 2024
1 parent 7ba1437 commit 4d11620
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
35 changes: 3 additions & 32 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 1 addition & 3 deletions stmps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -158,8 +157,7 @@ func main() {
osExit(2)
}

logger := logger.Init(*logFile)
defer logger.Close()
logger := logger.Init()
initCommandHandler(logger)

// init mpv engine
Expand Down

0 comments on commit 4d11620

Please sign in to comment.