Added log level to config

This commit is contained in:
Asaf Gartner 2021-05-06 12:12:18 +03:00
parent e8d1859d0a
commit d62f4ceeb6
4 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,7 @@ var Config = HMNConfig{
Env: Dev,
Addr: ":9001",
BaseUrl: "http://handmade.local:9001",
LogLevel: zerolog.TraceLevel,
Postgres: PostgresConfig{
User: "hmn",
Password: "password",

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/jackc/pgx/v4"
"github.com/rs/zerolog"
)
type Environment string
@ -18,6 +19,7 @@ type HMNConfig struct {
Env Environment
Addr string
BaseUrl string
LogLevel zerolog.Level
Postgres PostgresConfig
Auth AuthConfig
}

View File

@ -8,6 +8,7 @@ import (
"strings"
color "git.handmade.network/hmn/hmn/src/ansicolor"
"git.handmade.network/hmn/hmn/src/config"
"git.handmade.network/hmn/hmn/src/oops"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
@ -16,6 +17,7 @@ import (
func init() {
zerolog.ErrorStackMarshaler = oops.ZerologStackMarshaler
log.Logger = log.Output(NewPrettyZerologWriter())
zerolog.SetGlobalLevel(config.Config.LogLevel)
}
func GlobalLogger() *zerolog.Logger {

View File

@ -62,7 +62,7 @@ func Index(c *RequestContext) ResponseData {
allProjects := iterProjects.ToSlice()
c.Perf.EndBlock()
c.Logger.Info().Interface("allProjects", allProjects).Msg("all the projects")
c.Logger.Debug().Interface("allProjects", allProjects).Msg("all the projects")
categoryUrls := GetAllCategoryUrls(c.Context(), c.Conn)