improved log system

This commit is contained in:
2024-12-29 13:09:46 +01:00
parent c3c604d871
commit b69097e2a4
13 changed files with 247 additions and 111 deletions

21
main.go
View File

@@ -2,8 +2,14 @@ package main
import (
"embed"
"time"
"os"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
@@ -12,6 +18,16 @@ import (
var assets embed.FS
func main() {
// Configure the logger
log.Logger = log.Output(zerolog.ConsoleWriter{
Out: os.Stderr,
TimeFormat: "2006-01-02 15:04:05",
})
zerolog.TimestampFunc = func() time.Time {
return time.Now().Local()
}
zerolog.SetGlobalLevel(zerolog.TraceLevel)
// Create an instance of the app structure
app := NewApp()
@@ -28,9 +44,10 @@ func main() {
Bind: []interface{}{
app,
},
LogLevel: logger.ERROR,
})
if err != nil {
println("Error:", err.Error())
log.Err(err).Str("file", "main").Msg("unable to start the application")
}
}
}