feat: add debug mode logging support
This commit is contained in:
parent
670bc9d64c
commit
99d7b8347a
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue