feat(cfg): debug logging environment variable

Ayman Bagabas created

Change summary

server/config/config.go | 4 ++++
1 file changed, 4 insertions(+)

Detailed changes

server/config/config.go 🔗

@@ -22,6 +22,7 @@ type Config struct {
 	Port             int      `env:"SOFT_SERVE_PORT" envDefault:"23231"`
 	KeyPath          string   `env:"SOFT_SERVE_KEY_PATH"`
 	RepoPath         string   `env:"SOFT_SERVE_REPO_PATH" envDefault:".repos"`
+	Debug            bool     `env:"SOFT_SERVE_DEBUG" envDefault:"false"`
 	InitialAdminKeys []string `env:"SOFT_SERVE_INITIAL_ADMIN_KEY" envSeparator:"\n"`
 	Callbacks        Callbacks
 	ErrorLog         *glog.Logger
@@ -34,6 +35,9 @@ func DefaultConfig() *Config {
 	if err := env.Parse(cfg); err != nil {
 		log.Fatal(err)
 	}
+	if cfg.Debug {
+		log.SetLevel(log.DebugLevel)
+	}
 	if cfg.KeyPath == "" {
 		// NB: cross-platform-compatible path
 		cfg.KeyPath = filepath.Join(".ssh", "soft_serve_server_ed25519")