From b6cec3789342c2408d878359d4ed07e3789611ac Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 15 Sep 2022 23:10:16 -0600 Subject: caddyhttp: Add --debug flag to commands file-server and reverse-proxy This might be useful! --- modules/caddyhttp/fileserver/command.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'modules/caddyhttp/fileserver/command.go') diff --git a/modules/caddyhttp/fileserver/command.go b/modules/caddyhttp/fileserver/command.go index 902c5f8..6a77509 100644 --- a/modules/caddyhttp/fileserver/command.go +++ b/modules/caddyhttp/fileserver/command.go @@ -27,6 +27,7 @@ import ( "github.com/caddyserver/caddy/v2/modules/caddyhttp" caddytpl "github.com/caddyserver/caddy/v2/modules/caddyhttp/templates" "github.com/caddyserver/certmagic" + "go.uber.org/zap" ) func init() { @@ -70,6 +71,7 @@ func cmdFileServer(fs caddycmd.Flags) (int, error) { browse := fs.Bool("browse") templates := fs.Bool("templates") accessLog := fs.Bool("access-log") + debug := fs.Bool("debug") var handlers []json.RawMessage @@ -130,6 +132,14 @@ func cmdFileServer(fs caddycmd.Flags) (int, error) { }, } + if debug { + cfg.Logging = &caddy.Logging{ + Logs: map[string]*caddy.CustomLog{ + "default": {Level: zap.DebugLevel.CapitalString()}, + }, + } + } + err := caddy.Run(cfg) if err != nil { return caddy.ExitCodeFailedStartup, err -- cgit v1.2.3