From 7f84f33c1ce0bbbd4e7ed6e80c87d397f371c7ac Mon Sep 17 00:00:00 2001 From: Cornelius Rautenbach <cornel.rautenbach@gmail.com> Date: Mon, 22 Nov 2021 17:43:18 +0200 Subject: [PATCH] Code cleanup --- logger/db.go | 4 ++-- logger/fields.go | 3 --- logger/format.go | 12 +----------- 3 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 logger/fields.go diff --git a/logger/db.go b/logger/db.go index c684855..5186700 100644 --- a/logger/db.go +++ b/logger/db.go @@ -9,11 +9,11 @@ import ( type DbLogger struct{} -func (d DbLogger) BeforeQuery(c context.Context, q *pg.QueryEvent) (context.Context, error) { +func (d DbLogger) BeforeQuery(c context.Context, _ *pg.QueryEvent) (context.Context, error) { return c, nil } -func (d DbLogger) AfterQuery(c context.Context, q *pg.QueryEvent) error { +func (d DbLogger) AfterQuery(_ context.Context, q *pg.QueryEvent) error { sql, _ := q.FormattedQuery() if os.Getenv("DEBUGGING") == "true" { Debugf(string(sql)) diff --git a/logger/fields.go b/logger/fields.go deleted file mode 100644 index 4133d9a..0000000 --- a/logger/fields.go +++ /dev/null @@ -1,3 +0,0 @@ -package logger - -type Fields map[string]interface{} diff --git a/logger/format.go b/logger/format.go index e960f81..3ee4993 100644 --- a/logger/format.go +++ b/logger/format.go @@ -16,10 +16,6 @@ type IFormatter interface { Color() string } -func NewJSON() IFormatter { - return formatterJSON{} -} - type formatterJSON struct{} func (f formatterJSON) Format(entry Entry) []byte { @@ -64,7 +60,6 @@ func (f formatterConsole) Format(entry Entry) []byte { red := color.New(color.FgRed).FprintfFunc() magenta := color.New(color.FgMagenta).FprintfFunc() yellow := color.New(color.FgYellow).FprintfFunc() - //blue := color.New(color.FgBlue).FprintfFunc() green := color.New(color.FgGreen).FprintfFunc() cyan := color.New(color.FgCyan).FprintfFunc() @@ -86,7 +81,7 @@ func (f formatterConsole) Format(entry Entry) []byte { cyan(buffer, fmt.Sprintf(" %-40.40s| ", source)) base := color.New(fgColors[colorNames[f.fg]], bgColors[colorNames[f.bg]]).FprintfFunc() - base(buffer, entry.Message) //buffer.Write([]byte(entry.Message)) + base(buffer, entry.Message) if len(entry.Data) > 0 { jsonData, _ := json.Marshal(entry.Data) @@ -141,10 +136,6 @@ func (f formatterConsole) NextColor() IFormatter { nextFg++ if nextFg >= len(fgColors) { nextFg = 0 - // nextBg++ - // if nextBg >= len(bgColors) { - // nextBg++ - // } } if nextFg != nextBg { break @@ -156,6 +147,5 @@ func (f formatterConsole) NextColor() IFormatter { fg: nextFg, bg: nextBg, } - //globalLogger.Debugf("NextColor return id=%d Color %s on %s", f.id, colorNames[f.fg], colorNames[f.bg]) return f } -- GitLab