From 2819f9653a9cf3e37c5c13bfe4863875d849d817 Mon Sep 17 00:00:00 2001 From: Audrius Karabanovas Date: Sat, 16 Dec 2023 19:26:18 +0200 Subject: [PATCH] change logger to stdlib, update dependencies --- cmd/abyss-blackbox/main.go | 6 +-- go.mod | 10 ++--- go.sum | 40 ++++--------------- internal/app/api/client/http-client.go | 2 +- internal/app/wiring.go | 28 ++++++++----- .../fittings/provider/tracker-provider.go | 3 +- internal/mainwindow/custom_widget.go | 2 +- internal/mainwindow/fittings_dialog.go | 2 +- 8 files changed, 38 insertions(+), 55 deletions(-) diff --git a/cmd/abyss-blackbox/main.go b/cmd/abyss-blackbox/main.go index fae7ad9..d848ac0 100644 --- a/cmd/abyss-blackbox/main.go +++ b/cmd/abyss-blackbox/main.go @@ -1,15 +1,15 @@ package main import ( + "log/slog" "os" - "golang.org/x/exp/slog" - "github.com/shivas/abyss-blackbox/internal/app" ) func main() { - slog.SetDefault(slog.New(slog.HandlerOptions{Level: slog.LevelDebug}.NewTextHandler(os.Stdout))) + logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug})) + slog.SetDefault(logger) err := app.Run() if err != nil { diff --git a/go.mod b/go.mod index a3abf70..71f00bd 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/shivas/abyss-blackbox -go 1.19 +go 1.21 require ( github.com/disintegration/gift v1.2.1 @@ -9,13 +9,13 @@ require ( github.com/lxn/win v0.0.0-20210218163916-a377121e959e github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/shivas/go-windows-hlp v0.1.0 - golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 - golang.org/x/sys v0.5.0 - google.golang.org/protobuf v1.28.1 + golang.org/x/sys v0.15.0 + google.golang.org/protobuf v1.31.0 ) require ( - golang.org/x/image v0.5.0 // indirect + github.com/google/go-cmp v0.6.0 // indirect + golang.org/x/image v0.14.0 // indirect gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect ) diff --git a/go.sum b/go.sum index 3791912..25b3a9f 100644 --- a/go.sum +++ b/go.sum @@ -4,7 +4,8 @@ github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1 github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/shivas/go-windows-hlp v0.1.0 h1:XhmyLPAoGRE1TUltSbZkacdTeqlXk3MY7pX+2OCxDfc= @@ -13,42 +14,17 @@ github.com/shivas/walk v0.0.0-20210212094857-c0397ac21ff8 h1:XfZohVxBfVEqR8waXYF github.com/shivas/walk v0.0.0-20210212094857-c0397ac21ff8/go.mod h1:mApxRmv/+YmW2b+EFVr2Ve7hhrxDicu73W+uP7Za+VE= github.com/shivas/win v0.0.0-20210625114026-3e83f2d215c6 h1:8rO0BcQ2beWFsbGqFOsJVF4ABpQlkPGFB/cw9RXILws= github.com/shivas/win v0.0.0-20210625114026-3e83f2d215c6/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI= -golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI= -golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4= +golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc= gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E= diff --git a/internal/app/api/client/http-client.go b/internal/app/api/client/http-client.go index a564bc0..3f72e74 100644 --- a/internal/app/api/client/http-client.go +++ b/internal/app/api/client/http-client.go @@ -2,11 +2,11 @@ package client import ( "fmt" + "log/slog" "net/http" "github.com/shivas/abyss-blackbox/internal/app/domain" "github.com/shivas/abyss-blackbox/internal/version" - "golang.org/x/exp/slog" ) const agent = "abyssal.space blackbox recorder %s" diff --git a/internal/app/wiring.go b/internal/app/wiring.go index 6c465f3..cfcca17 100644 --- a/internal/app/wiring.go +++ b/internal/app/wiring.go @@ -4,10 +4,10 @@ import ( "errors" "fmt" "image" - "log" + "log/slog" + "os" "github.com/lxn/walk" - "golang.org/x/exp/slog" "github.com/shivas/abyss-blackbox/internal/app/api/client" "github.com/shivas/abyss-blackbox/internal/app/domain" @@ -248,7 +248,8 @@ func Run() (err error) { defer func() { err = config.Write(currentSettings) if err != nil { - log.Fatalf("failed to save settings after main window close: %v", err) + slog.Error("failed to save settings after main window close: %v", err) + os.Exit(1) } }() @@ -262,38 +263,45 @@ func createNotificationIcon(mw *walk.MainWindow) *walk.NotifyIcon { // We load our icon from a file. icon, err := walk.Resources.Icon("7") if err != nil { - log.Fatal(err) + slog.Error(err.Error()) + os.Exit(1) } // Create the notify icon and make sure we clean it up on exit. ni, err := walk.NewNotifyIcon(mw) if err != nil { - log.Fatal(err) + slog.Error(err.Error()) + os.Exit(1) } // Set the icon and a tool tip text. if err := ni.SetIcon(icon); err != nil { - log.Fatal(err) + slog.Error(err.Error()) + os.Exit(1) } if err := ni.SetToolTip("Click for info or use the context menu to exit."); err != nil { - log.Fatal(err) + slog.Error(err.Error()) + os.Exit(1) } // We put an exit action into the context menu. exitAction := walk.NewAction() if err := exitAction.SetText("E&xit"); err != nil { - log.Fatal(err) + slog.Error(err.Error()) + os.Exit(1) } exitAction.Triggered().Attach(func() { walk.App().Exit(0) }) if err := ni.ContextMenu().Actions().Add(exitAction); err != nil { - log.Fatal(err) + slog.Error(err.Error()) + os.Exit(1) } if err := ni.SetVisible(true); err != nil { - log.Fatal(err) + slog.Error(err.Error()) + os.Exit(1) } return ni diff --git a/internal/fittings/provider/tracker-provider.go b/internal/fittings/provider/tracker-provider.go index 7ce2fb9..2774cbe 100644 --- a/internal/fittings/provider/tracker-provider.go +++ b/internal/fittings/provider/tracker-provider.go @@ -4,9 +4,8 @@ import ( "context" "encoding/json" "fmt" + "log/slog" "net/http" - - "golang.org/x/exp/slog" ) const ( diff --git a/internal/mainwindow/custom_widget.go b/internal/mainwindow/custom_widget.go index 37ef696..6c469fd 100644 --- a/internal/mainwindow/custom_widget.go +++ b/internal/mainwindow/custom_widget.go @@ -3,6 +3,7 @@ package mainwindow import ( "image" "image/color" + "log/slog" "os" "time" @@ -11,7 +12,6 @@ import ( "github.com/lxn/win" "github.com/shivas/abyss-blackbox/internal/config" "github.com/shivas/abyss-blackbox/internal/screen" - "golang.org/x/exp/slog" ) func CustomWidgetDrawLoop( diff --git a/internal/mainwindow/fittings_dialog.go b/internal/mainwindow/fittings_dialog.go index b50e67e..42ddb6e 100644 --- a/internal/mainwindow/fittings_dialog.go +++ b/internal/mainwindow/fittings_dialog.go @@ -4,13 +4,13 @@ import ( "context" "fmt" "log" + "log/slog" "sort" "time" "github.com/lxn/walk" . "github.com/lxn/walk/declarative" //nolint:stylecheck,revive // we needs side effects "github.com/shivas/abyss-blackbox/internal/fittings" - "golang.org/x/exp/slog" fittingspb "github.com/shivas/abyss-blackbox/internal/fittings/pb" )