Skip to content

Commit

Permalink
Added option to disable AssetServer logging.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
leaanthony committed Jan 9, 2024
1 parent 68b12d4 commit 6c3bd12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion v3/pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions v3/pkg/application/options_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6c3bd12

Please sign in to comment.