Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: troubleshooting flagd
If a flag or targeting rule isn't proceeding the way you'd expect, you may want to enable more verbose logging.

flagd and flagd providers typically have debug or verbose logging modes that you can use for this sort of troubleshooting.
You can do this in the standalone version of flagd by starting it with the `--debug` flag (see [CLI](./reference/flagd-cli/flagd.md) for more information).
You can do this in the standalone version of flagd by starting it with the `--debug` flag (see [CLI](./reference/flagd-cli/flagd.md) for more information) or through `FLAGD_DEBUG` env variable.

_In-process_ providers which embed the flag evaluation engine use a logging consistent with their implementation language and SDK.
See your provider's documentation for details on how to enable verbose logging.
Expand Down
5 changes: 5 additions & 0 deletions flagd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ func init() {
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd.PersistentFlags().BoolVarP(&Debug, "debug", "x", false, "verbose logging")
// Bind the cobra flag to viper key
if err := viper.BindPFlag("debug", rootCmd.PersistentFlags().Lookup("debug")); err != nil {
fmt.Fprintln(os.Stderr, "error when binding flags", err.Error())
}
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.agent.yaml)")
rootCmd.AddCommand(startCmd)
rootCmd.AddCommand(versionCmd)
Expand All @@ -69,6 +73,7 @@ func initConfig() {
}

viper.AutomaticEnv() // read in environment variables that match
Debug = viper.GetBool("debug")

// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
Expand Down