feat: add debug mode logging support

This commit is contained in:
Derrick Hammer 2023-06-06 16:37:22 -04:00
parent 670bc9d64c
commit 99d7b8347a
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 10 additions and 1 deletions

View File

@ -25,6 +25,7 @@ func Init() {
pflag.String("database.name", "lumeweb_portal", "Database name")
pflag.String("database.path", "./db.sqlite", "Database path for SQLite")
pflag.String("renterd-api-password", ".", "admin password for renterd")
pflag.Bool("debug", false, "enable debug mode")
pflag.Parse()
err := viper.BindPFlags(pflag.CommandLine)

View File

@ -1,6 +1,7 @@
package logger
import (
"github.com/spf13/viper"
"go.uber.org/zap"
"log"
)
@ -8,7 +9,14 @@ import (
var logger *zap.Logger
func Init() {
newLogger, err := zap.NewProduction()
var newLogger *zap.Logger
var err error
if viper.GetBool("debug") {
newLogger, err = zap.NewDevelopment()
} else {
newLogger, err = zap.NewProduction()
}
if err != nil {
log.Fatal(err)