5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-19 02:19:31 +08:00

[v3] Use system logger instead of println

This commit is contained in:
Lea Anthony 2023-08-28 20:30:40 +10:00
parent 6edd667bdf
commit d44c8eba1c
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
9 changed files with 13 additions and 16 deletions

View File

@ -88,7 +88,7 @@ func New(appOptions Options) *App {
result.bindings, err = NewBindings(appOptions.Bind, appOptions.BindAliases) result.bindings, err = NewBindings(appOptions.Bind, appOptions.BindAliases)
if err != nil { if err != nil {
println("Fatal error in application initialisation: ", err.Error()) globalApplication.fatal("Fatal error in application initialisation: " + err.Error())
os.Exit(1) os.Exit(1)
} }
@ -101,7 +101,7 @@ func New(appOptions Options) *App {
err = result.bindings.AddPlugins(appOptions.Plugins) err = result.bindings.AddPlugins(appOptions.Plugins)
if err != nil { if err != nil {
println("Fatal error in application initialisation: ", err.Error()) globalApplication.fatal("Fatal error in application initialisation: " + err.Error())
os.Exit(1) os.Exit(1)
} }

View File

@ -306,7 +306,7 @@ func (m *windowsApp) unregisterWindow(w *windowsWebviewWindow) {
func newPlatformApp(app *App) *windowsApp { func newPlatformApp(app *App) *windowsApp {
err := w32.SetProcessDPIAware() err := w32.SetProcessDPIAware()
if err != nil { if err != nil {
println("Fatal error in application initialisation: ", err.Error()) globalApplication.fatal("Fatal error in application initialisation: ", err.Error())
os.Exit(1) os.Exit(1)
} }

View File

@ -204,7 +204,7 @@ func showCfdDialog(newDlg func() (cfd.Dialog, error), isMultiSelect bool) (any,
defer func() { defer func() {
err := dlg.Release() err := dlg.Release()
if err != nil { if err != nil {
println("ERROR: Unable to release dialog:", err.Error()) globalApplication.error("Unable to release dialog: " + err.Error())
} }
}() }()

View File

@ -1,6 +1,7 @@
package application package application
import ( import (
"fmt"
"os" "os"
"sync" "sync"
"sync/atomic" "sync/atomic"
@ -179,7 +180,7 @@ func newRole(role Role) *MenuItem {
return newFullScreenMenuItem() return newFullScreenMenuItem()
default: default:
println("No support for role:", role) globalApplication.error(fmt.Sprintf("No support for role: %v", role))
os.Exit(1) os.Exit(1)
} }
return nil return nil
@ -219,7 +220,7 @@ func (m *MenuItem) handleClick() {
func (m *MenuItem) SetAccelerator(shortcut string) *MenuItem { func (m *MenuItem) SetAccelerator(shortcut string) *MenuItem {
accelerator, err := parseAccelerator(shortcut) accelerator, err := parseAccelerator(shortcut)
if err != nil { if err != nil {
println("ERROR: invalid accelerator:", err.Error()) globalApplication.error("invalid accelerator:", err.Error())
return m return m
} }
m.accelerator = accelerator m.accelerator = accelerator

View File

@ -46,7 +46,7 @@ func systrayClickCallback(id C.long, buttonID C.int) {
// Get the system tray // Get the system tray
systemTray := systemTrayMap[uint(id)] systemTray := systemTrayMap[uint(id)]
if systemTray == nil { if systemTray == nil {
println("system tray not found") globalApplication.error("system tray not found", "id", id)
return return
} }
systemTray.processClick(button(buttonID)) systemTray.processClick(button(buttonID))

View File

@ -167,7 +167,7 @@ func (s *windowsSystemTray) run() {
// Set Default Callbacks // Set Default Callbacks
if s.parent.clickHandler == nil { if s.parent.clickHandler == nil {
s.parent.clickHandler = func() { s.parent.clickHandler = func() {
println("Left Button Clicked") globalApplication.info("Left Button Clicked")
} }
} }
if s.parent.rightClickHandler == nil { if s.parent.rightClickHandler == nil {

View File

@ -846,12 +846,12 @@ func (w *macosWebviewWindow) toggleDevTools() {
func (w *macosWebviewWindow) reload() { func (w *macosWebviewWindow) reload() {
//TODO: Implement //TODO: Implement
println("reload called on WebviewWindow", w.parent.id) globalApplication.info("reload called on WebviewWindow", "parentID", w.parent.id)
} }
func (w *macosWebviewWindow) forceReload() { func (w *macosWebviewWindow) forceReload() {
//TODO: Implement //TODO: Implement
println("forceReload called on WebviewWindow", w.parent.id) globalApplication.info("force reload called on WebviewWindow", "parentID", w.parent.id)
} }
func (w *macosWebviewWindow) center() { func (w *macosWebviewWindow) center() {

View File

@ -64,11 +64,7 @@ func SetTheme(hwnd uintptr, useDarkMode bool) {
} }
func EnableTranslucency(hwnd uintptr, backdrop int32) { func EnableTranslucency(hwnd uintptr, backdrop int32) {
if SupportsBackdropTypes() { dwmSetWindowAttribute(hwnd, DwmwaSystemBackdropType, unsafe.Pointer(&backdrop), unsafe.Sizeof(backdrop))
dwmSetWindowAttribute(hwnd, DwmwaSystemBackdropType, unsafe.Pointer(&backdrop), unsafe.Sizeof(backdrop))
} else {
println("Warning: Translucency type unavailable on Windows < 22621")
}
} }
func SetTitleBarColour(hwnd uintptr, titleBarColour int32) { func SetTitleBarColour(hwnd uintptr, titleBarColour int32) {

View File

@ -39,7 +39,7 @@ func (kvs *KeyValueStore) Shutdown() {
if kvs.unsaved { if kvs.unsaved {
err := kvs.Save() err := kvs.Save()
if err != nil { if err != nil {
println("Error saving store: " + err.Error()) application.Get().Logger.Error("Error saving store: " + err.Error())
} }
} }
} }