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

Added option to disable AssetServer logging.

An option to disable AssetServer logging has been introduced in the application options. This will suppress every request log from the AssetServer if set to true. This adjustment is useful for preventing log saturation in certain scenarios or environments.
This commit is contained in:
Lea Anthony 2024-01-09 22:15:42 +11:00
parent 68b12d4fff
commit 6c3bd124ce
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
2 changed files with 9 additions and 1 deletions

View File

@ -74,7 +74,12 @@ func New(appOptions Options) *App {
Middleware: assetserver.Middleware(appOptions.Assets.Middleware),
}
srv, err := assetserver.NewAssetServer(opts, false, result.Logger, wailsruntime.RuntimeAssetsBundle, result.isDebugMode, NewMessageProcessor(result.Logger))
assetLogger := result.Logger
if appOptions.Assets.DisableLogging {
assetLogger = slog.New(slog.NewTextHandler(io.Discard, nil))
}
srv, err := assetserver.NewAssetServer(opts, false, assetLogger, wailsruntime.RuntimeAssetsBundle, result.isDebugMode, NewMessageProcessor(result.Logger))
if err != nil {
result.Logger.Error("Fatal error in application initialisation: " + err.Error())
os.Exit(1)

View File

@ -80,6 +80,9 @@ type AssetOptions struct {
// Multiple Middlewares can be chained together with:
// ChainMiddleware(middleware ...Middleware) Middleware
Middleware Middleware
// DisableLogging disables logging of the AssetServer. By default, the AssetServer logs every request.
DisableLogging bool
}
// Middleware defines HTTP middleware that can be applied to the AssetServer.