headscale/cmd/headscale/headscale.go

44 lines
875 B
Go
Raw Permalink Normal View History

2020-06-21 10:33:43 +00:00
package main
import (
2021-08-05 18:19:25 +00:00
"os"
"time"
2020-06-21 10:33:43 +00:00
"github.com/efekarakus/termcolor"
"github.com/juanfont/headscale/cmd/headscale/cli"
2021-08-05 18:19:25 +00:00
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
2020-06-21 10:33:43 +00:00
)
2021-04-25 15:24:42 +00:00
func main() {
var colors bool
switch l := termcolor.SupportLevel(os.Stderr); l {
case termcolor.Level16M:
colors = true
case termcolor.Level256:
colors = true
case termcolor.LevelBasic:
colors = true
2021-11-14 16:52:55 +00:00
case termcolor.LevelNone:
colors = false
default:
// no color, return text as is.
colors = false
}
// Adhere to no-color.org manifesto of allowing users to
// turn off color in cli/services
if _, noColorIsSet := os.LookupEnv("NO_COLOR"); noColorIsSet {
colors = false
}
2021-08-05 18:19:25 +00:00
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
log.Logger = log.Output(zerolog.ConsoleWriter{
Out: os.Stdout,
TimeFormat: time.RFC3339,
NoColor: !colors,
2021-08-05 18:19:25 +00:00
})
2021-07-25 13:14:09 +00:00
cli.Execute()
}