This commit is contained in:
2019-12-22 01:17:18 +05:00
parent da4bc379d8
commit a52b18ffe4
31 changed files with 202 additions and 82 deletions

View File

@@ -46,7 +46,7 @@ import (
// contains everything every part of application need, like configuration
// access, logger, etc.
type Context struct {
Config *config.ConfigStruct
Config *config.Struct
Database databaseinterface.Interface
Echo *echo.Echo
Flagger *flagger.Flagger
@@ -104,7 +104,7 @@ func (c *Context) LoadConfiguration() {
c.Logger.Debug().Msgf("Configuration file path: %s", configPath)
c.Config = &config.ConfigStruct{}
c.Config = &config.Struct{}
// Read configuration file.
fileData, err2 := ioutil.ReadFile(normalizedConfigPath)

View File

@@ -15,6 +15,7 @@ import (
// Puts memory usage into log lines.
func (c *Context) getMemoryUsage(e *zerolog.Event, level zerolog.Level, message string) {
var m runtime.MemStats
runtime.ReadMemStats(&m)
e.Str("memalloc", fmt.Sprintf("%dMB", m.Alloc/1024/1024))
@@ -28,6 +29,7 @@ func (c *Context) initializeLogger() {
output := zerolog.ConsoleWriter{Out: os.Stdout, NoColor: false, TimeFormat: time.RFC3339}
output.FormatLevel = func(i interface{}) string {
var v string
if ii, ok := i.(string); ok {
ii = strings.ToUpper(ii)
switch ii {
@@ -47,6 +49,7 @@ func (c *Context) initializeLogger() {
v = ii
}
}
return fmt.Sprintf("| %s |", v)
}
@@ -59,6 +62,7 @@ func (c *Context) initializeLogger() {
func (c *Context) initializeLoggerPost() {
// Set log level.
c.Logger.Info().Msgf("Setting logger level: %s", c.Config.Logging.LogLevel)
switch c.Config.Logging.LogLevel {
case "DEBUG":
zerolog.SetGlobalLevel(zerolog.DebugLevel)