Use structured logging for demo app
This commit is contained in:
@ -6,12 +6,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"gitlab.com/wpetit/goweb/logger"
|
||||
|
||||
"github.com/caarlos0/env/v6"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Log LogConfig `yaml:"log"`
|
||||
HTTP HTTPConfig `yaml:"http"`
|
||||
OIDC OIDCConfig `yaml:"oidc"`
|
||||
}
|
||||
@ -49,6 +51,11 @@ type OIDCConfig struct {
|
||||
PostLogoutRedirectURL string `yaml:"postLogoutRedirectURL" env:"OIDC_POST_LOGOUT_REDIRECT_URL"`
|
||||
}
|
||||
|
||||
type LogConfig struct {
|
||||
Level logger.Level `yaml:"level" env:"LOG_LEVEL"`
|
||||
Format logger.Format `yaml:"format" env:"LOG_FORMAT"`
|
||||
}
|
||||
|
||||
func NewDumpDefault() *Config {
|
||||
config := NewDefault()
|
||||
return config
|
||||
@ -56,6 +63,10 @@ func NewDumpDefault() *Config {
|
||||
|
||||
func NewDefault() *Config {
|
||||
return &Config{
|
||||
Log: LogConfig{
|
||||
Level: logger.LevelWarn,
|
||||
Format: logger.FormatHuman,
|
||||
},
|
||||
HTTP: HTTPConfig{
|
||||
Address: ":3002",
|
||||
CookieAuthenticationKey: "",
|
||||
|
Reference in New Issue
Block a user