Files
akvorado/cmd/root.go
Vincent Bernat 5c3d217fed doc: hydrate → enrich
It seems that "to hydrate" is incorrect. The correct term would be "to
enrich".
2022-11-08 15:00:24 +01:00

41 lines
961 B
Go

// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
// Package cmd handles the command-line interface for akvorado
package cmd
import (
"os"
"github.com/mattn/go-isatty"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
var debug bool
// RootCmd is the root for all commands
var RootCmd = &cobra.Command{
Use: "akvorado",
Short: "Flow collector, enricher and visualizer",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if isatty.IsTerminal(os.Stdout.Fd()) {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
} else {
log.Logger = zerolog.New(os.Stdout).With().Timestamp().Logger()
}
zerolog.SetGlobalLevel(zerolog.InfoLevel)
if debug {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
},
SilenceErrors: true,
SilenceUsage: true,
}
func init() {
RootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false,
"Enable debug logs")
}