Make linter happy and update dependencies.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-06-26 22:26:39 +05:00
parent 7b6a425908
commit f8f0302564
30 changed files with 325 additions and 363 deletions

View File

@@ -100,7 +100,7 @@ func (c *Context) LoadConfiguration() {
c.Logger.Debug().Str("path", configPath).Msg("Configuration file path")
// nolint:exhaustivestruct
// nolint:exhaustruct
c.Config = &config.Struct{}
// Read configuration file.

View File

@@ -31,6 +31,6 @@ const (
// New creates new context.
func New() *Context {
// nolint:exhaustivestruct
// nolint:exhaustruct
return &Context{}
}

View File

@@ -12,44 +12,44 @@ import (
// Puts memory usage into log lines.
func (c *Context) getMemoryUsage(event *zerolog.Event, level zerolog.Level, message string) {
var m runtime.MemStats
var memstats runtime.MemStats
runtime.ReadMemStats(&m)
runtime.ReadMemStats(&memstats)
event.Str("memalloc", fmt.Sprintf("%dMB", m.Alloc/1024/1024))
event.Str("memsys", fmt.Sprintf("%dMB", m.Sys/1024/1024))
event.Str("numgc", fmt.Sprintf("%d", m.NumGC))
event.Str("memalloc", fmt.Sprintf("%dMB", memstats.Alloc/1024/1024))
event.Str("memsys", fmt.Sprintf("%dMB", memstats.Sys/1024/1024))
event.Str("numgc", fmt.Sprintf("%d", memstats.NumGC))
}
// Initializes logger.
func (c *Context) initializeLogger() {
// Устанавливаем форматирование логгера.
// nolint:exhaustivestruct
// nolint:exhaustruct
output := zerolog.ConsoleWriter{Out: os.Stdout, NoColor: false, TimeFormat: time.RFC3339}
output.FormatLevel = func(lvlRaw interface{}) string {
var v string
var lvl string
if lvl, ok := lvlRaw.(string); ok {
lvl = strings.ToUpper(lvl)
switch lvl {
if lvlAsString, ok := lvlRaw.(string); ok {
lvlAsString = strings.ToUpper(lvlAsString)
switch lvlAsString {
case "DEBUG":
v = fmt.Sprintf("\x1b[30m%-5s\x1b[0m", lvl)
lvl = fmt.Sprintf("\x1b[30m%-5s\x1b[0m", lvlAsString)
case "ERROR":
v = fmt.Sprintf("\x1b[31m%-5s\x1b[0m", lvl)
lvl = fmt.Sprintf("\x1b[31m%-5s\x1b[0m", lvlAsString)
case "FATAL":
v = fmt.Sprintf("\x1b[35m%-5s\x1b[0m", lvl)
lvl = fmt.Sprintf("\x1b[35m%-5s\x1b[0m", lvlAsString)
case "INFO":
v = fmt.Sprintf("\x1b[32m%-5s\x1b[0m", lvl)
lvl = fmt.Sprintf("\x1b[32m%-5s\x1b[0m", lvlAsString)
case "PANIC":
v = fmt.Sprintf("\x1b[36m%-5s\x1b[0m", lvl)
lvl = fmt.Sprintf("\x1b[36m%-5s\x1b[0m", lvlAsString)
case "WARN":
v = fmt.Sprintf("\x1b[33m%-5s\x1b[0m", lvl)
lvl = fmt.Sprintf("\x1b[33m%-5s\x1b[0m", lvlAsString)
default:
v = lvl
lvl = lvlAsString
}
}
return fmt.Sprintf("| %s |", v)
return fmt.Sprintf("| %s |", lvl)
}
c.Logger = zerolog.New(output).With().Timestamp().Logger()