Make logging configurable

This commit is contained in:
Ilja Neumann
2020-04-29 14:10:33 +02:00
committed by Ilja Neumann
parent 8847024077
commit b7fb179dec
4 changed files with 50 additions and 8 deletions
+27
View File
@@ -3,6 +3,33 @@ package flagset
import "github.com/micro/cli/v2"
import "github.com/owncloud/ocis-accounts/pkg/config"
// RootWithConfig applies cfg to the root flagset
func RootWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "log-level",
Value: "info",
Usage: "Set logging level",
EnvVars: []string{"ACCOUNTS_LOG_LEVEL"},
Destination: &cfg.Log.Level,
},
&cli.BoolFlag{
Value: true,
Name: "log-pretty",
Usage: "Enable pretty logging",
EnvVars: []string{"ACCOUNTS_LOG_PRETTY"},
Destination: &cfg.Log.Pretty,
},
&cli.BoolFlag{
Value: true,
Name: "log-color",
Usage: "Enable colored logging",
EnvVars: []string{"ACCOUNTS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
}
}
// ServerWithConfig applies cfg to the root flagset
func ServerWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{