mirror of
https://github.com/go-acme/lego
synced 2026-03-14 14:35:48 +01:00
review: color and TTY
This commit is contained in:
parent
6f81bffb9d
commit
8c5722bb69
1 changed files with 10 additions and 3 deletions
13
cmd/cmd.go
13
cmd/cmd.go
|
|
@ -7,6 +7,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/go-acme/lego/v5/log"
|
||||
"github.com/mattn/go-isatty"
|
||||
"github.com/urfave/cli/v3"
|
||||
"gitlab.com/greyxor/slogor"
|
||||
)
|
||||
|
|
@ -60,10 +61,16 @@ func setUpLogger(cmd *cli.Command) {
|
|||
logger = slog.New(slog.NewTextHandler(os.Stdout, opts))
|
||||
|
||||
default:
|
||||
logger = slog.New(slogor.NewHandler(os.Stderr,
|
||||
opts := []slogor.OptionFn{
|
||||
slogor.SetLevel(getLogLeveler(cmd.String(flgLogLevel))),
|
||||
slogor.SetTimeFormat(rfc3339NanoNatural)),
|
||||
)
|
||||
slogor.SetTimeFormat(rfc3339NanoNatural),
|
||||
}
|
||||
|
||||
if !isatty.IsTerminal(os.Stdout.Fd()) {
|
||||
opts = append(opts, slogor.DisableColor())
|
||||
}
|
||||
|
||||
logger = slog.New(slogor.NewHandler(os.Stdout, opts...))
|
||||
}
|
||||
|
||||
log.SetDefault(logger)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue