Added log level to config
This commit is contained in:
parent
e8d1859d0a
commit
d62f4ceeb6
|
@ -4,6 +4,7 @@ var Config = HMNConfig{
|
||||||
Env: Dev,
|
Env: Dev,
|
||||||
Addr: ":9001",
|
Addr: ":9001",
|
||||||
BaseUrl: "http://handmade.local:9001",
|
BaseUrl: "http://handmade.local:9001",
|
||||||
|
LogLevel: zerolog.TraceLevel,
|
||||||
Postgres: PostgresConfig{
|
Postgres: PostgresConfig{
|
||||||
User: "hmn",
|
User: "hmn",
|
||||||
Password: "password",
|
Password: "password",
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jackc/pgx/v4"
|
"github.com/jackc/pgx/v4"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Environment string
|
type Environment string
|
||||||
|
@ -18,6 +19,7 @@ type HMNConfig struct {
|
||||||
Env Environment
|
Env Environment
|
||||||
Addr string
|
Addr string
|
||||||
BaseUrl string
|
BaseUrl string
|
||||||
|
LogLevel zerolog.Level
|
||||||
Postgres PostgresConfig
|
Postgres PostgresConfig
|
||||||
Auth AuthConfig
|
Auth AuthConfig
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
color "git.handmade.network/hmn/hmn/src/ansicolor"
|
color "git.handmade.network/hmn/hmn/src/ansicolor"
|
||||||
|
"git.handmade.network/hmn/hmn/src/config"
|
||||||
"git.handmade.network/hmn/hmn/src/oops"
|
"git.handmade.network/hmn/hmn/src/oops"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
@ -16,6 +17,7 @@ import (
|
||||||
func init() {
|
func init() {
|
||||||
zerolog.ErrorStackMarshaler = oops.ZerologStackMarshaler
|
zerolog.ErrorStackMarshaler = oops.ZerologStackMarshaler
|
||||||
log.Logger = log.Output(NewPrettyZerologWriter())
|
log.Logger = log.Output(NewPrettyZerologWriter())
|
||||||
|
zerolog.SetGlobalLevel(config.Config.LogLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GlobalLogger() *zerolog.Logger {
|
func GlobalLogger() *zerolog.Logger {
|
||||||
|
|
|
@ -62,7 +62,7 @@ func Index(c *RequestContext) ResponseData {
|
||||||
|
|
||||||
allProjects := iterProjects.ToSlice()
|
allProjects := iterProjects.ToSlice()
|
||||||
c.Perf.EndBlock()
|
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)
|
categoryUrls := GetAllCategoryUrls(c.Context(), c.Conn)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue