diff --git a/pkg/datalogger/wideband.go b/pkg/datalogger/wideband.go index 4659fd7..2cf2aab 100644 --- a/pkg/datalogger/wideband.go +++ b/pkg/datalogger/wideband.go @@ -8,8 +8,8 @@ import ( "github.com/roffe/gocan" "github.com/roffe/gocan/adapter" - "github.com/roffe/txlogger/pkg/ecumaster" "github.com/roffe/txlogger/pkg/wbl/aem" + "github.com/roffe/txlogger/pkg/wbl/ecumaster" "github.com/roffe/txlogger/pkg/wbl/innovate" ) diff --git a/pkg/debug/debug.go b/pkg/debug/debug.go index 57713d9..bfc8854 100644 --- a/pkg/debug/debug.go +++ b/pkg/debug/debug.go @@ -6,18 +6,24 @@ import ( "os" "path/filepath" "runtime" + "sync" "time" ) -func init() { +var initOnce sync.Once +var fh *os.File + +func start() { var err error - f, err = os.OpenFile("debug.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) + fh, err = os.OpenFile("debug.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) if err != nil { log.Printf("error opening file: %v", err) } } func Log(msg string) { + initOnce.Do(start) + timeStr := time.Now().Format("2006-01-02 15:04:05.000") _, fullPath, line, ok := runtime.Caller(2) filename := filepath.Base(fullPath) @@ -28,20 +34,18 @@ func Log(msg string) { } } -var f *os.File - func LogRaw(msg string) { - if f == nil { + if fh == nil { var err error - f, err = os.OpenFile("debug.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) + fh, err = os.OpenFile("debug.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0644) if err == nil { log.Println("error opening file: %w", err) return } } - f.WriteString(msg + "\n") + fh.WriteString(msg + "\n") } func Close() { - f.Sync() - f.Close() + fh.Sync() + fh.Close() } diff --git a/pkg/snd/pedro.mp3 b/pkg/internal/snd/pedro.mp3 similarity index 100% rename from pkg/snd/pedro.mp3 rename to pkg/internal/snd/pedro.mp3 diff --git a/pkg/snd/snd.go b/pkg/internal/snd/snd.go similarity index 100% rename from pkg/snd/snd.go rename to pkg/internal/snd/snd.go diff --git a/pkg/ecumaster/ecumaster.go b/pkg/wbl/ecumaster/ecumaster.go similarity index 100% rename from pkg/ecumaster/ecumaster.go rename to pkg/wbl/ecumaster/ecumaster.go diff --git a/pkg/multiwindow/base.go b/pkg/widgets/multiwindow/base.go similarity index 100% rename from pkg/multiwindow/base.go rename to pkg/widgets/multiwindow/base.go diff --git a/pkg/multiwindow/innerwindow.go b/pkg/widgets/multiwindow/innerwindow.go similarity index 100% rename from pkg/multiwindow/innerwindow.go rename to pkg/widgets/multiwindow/innerwindow.go diff --git a/pkg/multiwindow/multiplewindows.go b/pkg/widgets/multiwindow/multiplewindows.go similarity index 100% rename from pkg/multiwindow/multiplewindows.go rename to pkg/widgets/multiwindow/multiplewindows.go diff --git a/pkg/multiwindow/shadow.go b/pkg/widgets/multiwindow/shadow.go similarity index 100% rename from pkg/multiwindow/shadow.go rename to pkg/widgets/multiwindow/shadow.go diff --git a/pkg/multiwindow/shadowing_renderer.go b/pkg/widgets/multiwindow/shadowing_renderer.go similarity index 100% rename from pkg/multiwindow/shadowing_renderer.go rename to pkg/widgets/multiwindow/shadowing_renderer.go diff --git a/pkg/plotter/bresenham.go b/pkg/widgets/plotter/bresenham.go similarity index 100% rename from pkg/plotter/bresenham.go rename to pkg/widgets/plotter/bresenham.go diff --git a/pkg/plotter/plotter.go b/pkg/widgets/plotter/plotter.go similarity index 100% rename from pkg/plotter/plotter.go rename to pkg/widgets/plotter/plotter.go diff --git a/pkg/plotter/plotter_mouse.go b/pkg/widgets/plotter/plotter_mouse.go similarity index 100% rename from pkg/plotter/plotter_mouse.go rename to pkg/widgets/plotter/plotter_mouse.go diff --git a/pkg/plotter/plotter_render.go b/pkg/widgets/plotter/plotter_render.go similarity index 100% rename from pkg/plotter/plotter_render.go rename to pkg/widgets/plotter/plotter_render.go diff --git a/pkg/plotter/text.go b/pkg/widgets/plotter/text.go similarity index 100% rename from pkg/plotter/text.go rename to pkg/widgets/plotter/text.go diff --git a/pkg/widgets/settings/settings.go b/pkg/widgets/settings/settings.go index 6c61257..4e66c19 100644 --- a/pkg/widgets/settings/settings.go +++ b/pkg/widgets/settings/settings.go @@ -11,8 +11,8 @@ import ( "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" "github.com/roffe/txlogger/pkg/datalogger" - "github.com/roffe/txlogger/pkg/ecumaster" "github.com/roffe/txlogger/pkg/wbl/aem" + "github.com/roffe/txlogger/pkg/wbl/ecumaster" "github.com/roffe/txlogger/pkg/wbl/innovate" "github.com/roffe/txlogger/pkg/widgets/cansettings" sdialog "github.com/sqweek/dialog" diff --git a/pkg/windows/logplayer.go b/pkg/windows/logplayer.go index f639f35..f95fa2e 100644 --- a/pkg/windows/logplayer.go +++ b/pkg/windows/logplayer.go @@ -22,8 +22,8 @@ import ( "github.com/roffe/txlogger/pkg/layout" "github.com/roffe/txlogger/pkg/logfile" "github.com/roffe/txlogger/pkg/mainmenu" - "github.com/roffe/txlogger/pkg/plotter" "github.com/roffe/txlogger/pkg/widgets/dashboard" + "github.com/roffe/txlogger/pkg/widgets/plotter" ) const TIME_FORMAT = "02-01-2006 15:04:05.999" diff --git a/pkg/windows/mainWindow.go b/pkg/windows/mainWindow.go index c28d3d6..2f246e3 100644 --- a/pkg/windows/mainWindow.go +++ b/pkg/windows/mainWindow.go @@ -25,9 +25,9 @@ import ( "github.com/roffe/txlogger/pkg/debug" "github.com/roffe/txlogger/pkg/ecu" "github.com/roffe/txlogger/pkg/mainmenu" - "github.com/roffe/txlogger/pkg/multiwindow" "github.com/roffe/txlogger/pkg/presets" "github.com/roffe/txlogger/pkg/widgets/dashboard" + "github.com/roffe/txlogger/pkg/widgets/multiwindow" "github.com/roffe/txlogger/pkg/widgets/progressmodal" "github.com/roffe/txlogger/pkg/widgets/settings" "github.com/roffe/txlogger/pkg/widgets/symbollist" diff --git a/pkg/windows/mainWindow_buttons.go b/pkg/windows/mainWindow_buttons.go index 93dff36..084fc55 100644 --- a/pkg/windows/mainWindow_buttons.go +++ b/pkg/windows/mainWindow_buttons.go @@ -11,7 +11,7 @@ import ( "github.com/roffe/gocan" "github.com/roffe/txlogger/pkg/datalogger" "github.com/roffe/txlogger/pkg/ebus" - "github.com/roffe/txlogger/pkg/snd" + "github.com/roffe/txlogger/pkg/internal/snd" "github.com/roffe/txlogger/pkg/widgets/dashboard" sdialog "github.com/sqweek/dialog" ) diff --git a/pkg/windows/mainWindow_multiwindow.go b/pkg/windows/mainWindow_multiwindow.go index ca40c12..3835744 100644 --- a/pkg/windows/mainWindow_multiwindow.go +++ b/pkg/windows/mainWindow_multiwindow.go @@ -4,7 +4,7 @@ import ( "sync" "fyne.io/fyne/v2" - "github.com/roffe/txlogger/pkg/multiwindow" + "github.com/roffe/txlogger/pkg/widgets/multiwindow" ) type innerWindow struct {