diff --git a/Justfile b/Justfile index a5feb7a..3d23175 100644 --- a/Justfile +++ b/Justfile @@ -6,7 +6,7 @@ dev: export PAGES_DOMAIN=localhost.mock.directory export RAW_DOMAIN=raw.localhost.mock.directory export PORT=4430 - go run . + go run . --verbose build: CGO_ENABLED=0 go build -ldflags '-s -w' -v -o build/codeberg-pages-server ./ diff --git a/cmd/flags.go b/cmd/flags.go index c6eaf4f..e1838c2 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -5,6 +5,12 @@ import ( ) var ServeFlags = []cli.Flag{ + &cli.BoolFlag{ + Name: "verbose", + // TODO: Usage + EnvVars: []string{"DEBUG"}, + }, + // MainDomainSuffix specifies the main domain (starting with a dot) for which subdomains shall be served as static // pages, or used for comparison in CNAME lookups. Static pages can be accessed through // https://{owner}.{MainDomain}[/{repo}], with repo defaulting to "pages". diff --git a/cmd/main.go b/cmd/main.go index cd1a1c2..fb0c26e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/urfave/cli/v2" @@ -34,6 +35,11 @@ var BlacklistedPaths = [][]byte{ // Serve sets up and starts the web server. func Serve(ctx *cli.Context) error { + verbose := ctx.Bool("verbose") + if !verbose { + zerolog.SetGlobalLevel(zerolog.InfoLevel) + } + giteaRoot := strings.TrimSuffix(ctx.String("gitea-root"), "/") giteaAPIToken := ctx.String("gitea-api-token") rawDomain := ctx.String("raw-domain")