1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

WTF-400 Logger extracted to new config format

This commit is contained in:
Chris Cummer 2019-04-15 20:29:45 -07:00
parent fea83a38b2
commit 8bc217e9a1
4 changed files with 27 additions and 7 deletions

View File

@ -6,7 +6,7 @@ import (
"os" "os"
"github.com/olebedev/config" "github.com/olebedev/config"
"github.com/wtfutil/wtf/logger" // "github.com/wtfutil/wtf/logger"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
) )
@ -38,15 +38,13 @@ func MigrateOldConfig() {
err := Copy(srcDir, destDir) err := Copy(srcDir, destDir)
if err != nil { if err != nil {
panic(err) panic(err)
} else {
logger.Log(fmt.Sprintf("Copied old config from %s to %s", srcDir, destDir))
} }
// Delete the old directory if the new one exists // Delete the old directory if the new one exists
if _, err := os.Stat(destDir); err == nil { if _, err := os.Stat(destDir); err == nil {
err := os.RemoveAll(srcDir) err := os.RemoveAll(srcDir)
if err != nil { if err != nil {
logger.Log(err.Error()) fmt.Println(err)
} }
} }
} }

View File

@ -2,7 +2,6 @@ package logger
import ( import (
"fmt" "fmt"
//"io/ioutil"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
@ -18,13 +17,15 @@ type Widget struct {
wtf.TextWidget wtf.TextWidget
filePath string filePath string
settings *Settings
} }
func NewWidget(app *tview.Application) *Widget { func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(app, "Logs", "logger", true), TextWidget: wtf.NewTextWidget(app, "Logs", "logger", true),
filePath: logFilePath(), filePath: logFilePath(),
settings: settings,
} }
return &widget return &widget

20
logger/settings.go Normal file
View File

@ -0,0 +1,20 @@
package logger
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
type Settings struct {
common *cfg.Common
filePath string
}
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
}
return &settings
}

View File

@ -244,7 +244,8 @@ func makeWidget(app *tview.Application, pages *tview.Pages, widgetName string) w
settings := jira.NewSettingsFromYAML(wtf.Config) settings := jira.NewSettingsFromYAML(wtf.Config)
widget = jira.NewWidget(app, pages, settings) widget = jira.NewWidget(app, pages, settings)
case "logger": case "logger":
widget = logger.NewWidget(app) settings := logger.NewSettingsFromYAML(wtf.Config)
widget = logger.NewWidget(app, settings)
case "mercurial": case "mercurial":
widget = mercurial.NewWidget(app, pages) widget = mercurial.NewWidget(app, pages)
case "nbascore": case "nbascore":