Use structured logging for demo app

This commit is contained in:
2020-05-22 16:03:59 +02:00
parent e26cb7ad49
commit c2666086cb
4 changed files with 83 additions and 15 deletions

View File

@ -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: "",