mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-26 13:49:21 +08:00
create debugLog
This commit is contained in:
parent
ebc7985391
commit
9912995049
3
start.go
3
start.go
@ -27,7 +27,6 @@ func readConfig(args Args) {
|
||||
|
||||
configPath := *args.config
|
||||
musicDir := *args.music
|
||||
|
||||
home, err := os.UserHomeDir()
|
||||
|
||||
if err != nil {
|
||||
@ -126,7 +125,7 @@ func start(application *tview.Application, args Args) {
|
||||
gomu = newGomu()
|
||||
gomu.initPanels(application)
|
||||
|
||||
logError(fmt.Errorf("App start"))
|
||||
debugLog("App start")
|
||||
|
||||
flex := layout(gomu)
|
||||
gomu.pages.AddPage("main", flex, true, true)
|
||||
|
17
utils.go
17
utils.go
@ -33,6 +33,23 @@ func logError(err error) {
|
||||
log.Println(tracerr.SprintSource(err))
|
||||
}
|
||||
|
||||
func debugLog(val ...interface{}) {
|
||||
|
||||
tmpDir := os.TempDir()
|
||||
logFile := path.Join(tmpDir, "gomu.log")
|
||||
file, e := os.OpenFile(logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||
|
||||
if e != nil {
|
||||
log.Fatalf("Error opening file %s", logFile)
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
|
||||
log.SetOutput(file)
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Llongfile)
|
||||
log.Println(val...)
|
||||
}
|
||||
|
||||
// Wraps error in a formatted way.
|
||||
func wrapError(fnName string, err error) error {
|
||||
return fmt.Errorf("%s: \n%e", fnName, err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user