AllPac/pkg/logger/logger.go
VetheonGames 132740b7a1 Major Update 6 (Pre-Release Binary 0.8)
Changes to main.go:
```
- make needed changes to remove the flag package
- refactor functions to use the preferred command syntax
```

changes to logger.go:
```
- make logger be quiet and stop outputting to STDOUT now that we are in user testing
```

changes to install.go:
```
- setup some extra logic in InstallPAckageSnap to install snaps in "classic confinement mode" if the user wishes
```

changes to updater_utils.go:
```
- create the file to contain some helper methods (namely one to update packages by name from a more central interface)
```

changes to cli_utils.go:
```
- create the file to contain some helper methods for the CLI (namely just a method to handle errors in the update process)
```
2024-01-07 17:30:30 -07:00

58 lines
1.1 KiB
Go

package logger
import (
"log"
"os"
"path/filepath"
"fmt"
)
var Logger *log.Logger
func Init(logFilePath string) error {
if err := os.MkdirAll(filepath.Dir(logFilePath), 0755); err != nil {
return err
}
logFile, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
return err
}
Logger = log.New(logFile, "AllPac: ", log.Ldate|log.Ltime|log.Lshortfile)
return nil
}
func Info(v ...interface{}) {
Logger.Println("INFO: " + fmt.Sprint(v...))
}
func Infof(format string, v ...interface{}) {
Logger.Printf("INFO: "+format, v...)
}
func Warn(v ...interface{}) {
Logger.Println("WARN: " + fmt.Sprint(v...))
}
func Warnf(format string, v ...interface{}) {
Logger.Printf("WARN: "+format, v...)
}
func Error(v ...interface{}) {
Logger.Println("ERROR: " + fmt.Sprint(v...))
}
func Errorf(format string, v ...interface{}) {
Logger.Printf("ERROR: "+format, v...)
}
func Debug(v ...interface{}) {
Logger.Println("DEBUG: " + fmt.Sprint(v...))
}
func Debugf(format string, v ...interface{}) {
Logger.Printf("DEBUG: "+format, v...)
}