Skip to content
Snippets Groups Projects
Commit 7f84f33c authored by Cornel Rautenbach's avatar Cornel Rautenbach
Browse files

Code cleanup

parent 20799cce
No related branches found
No related tags found
No related merge requests found
...@@ -9,11 +9,11 @@ import ( ...@@ -9,11 +9,11 @@ import (
type DbLogger struct{} 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 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() sql, _ := q.FormattedQuery()
if os.Getenv("DEBUGGING") == "true" { if os.Getenv("DEBUGGING") == "true" {
Debugf(string(sql)) Debugf(string(sql))
......
package logger
type Fields map[string]interface{}
...@@ -16,10 +16,6 @@ type IFormatter interface { ...@@ -16,10 +16,6 @@ type IFormatter interface {
Color() string Color() string
} }
func NewJSON() IFormatter {
return formatterJSON{}
}
type formatterJSON struct{} type formatterJSON struct{}
func (f formatterJSON) Format(entry Entry) []byte { func (f formatterJSON) Format(entry Entry) []byte {
...@@ -64,7 +60,6 @@ func (f formatterConsole) Format(entry Entry) []byte { ...@@ -64,7 +60,6 @@ func (f formatterConsole) Format(entry Entry) []byte {
red := color.New(color.FgRed).FprintfFunc() red := color.New(color.FgRed).FprintfFunc()
magenta := color.New(color.FgMagenta).FprintfFunc() magenta := color.New(color.FgMagenta).FprintfFunc()
yellow := color.New(color.FgYellow).FprintfFunc() yellow := color.New(color.FgYellow).FprintfFunc()
//blue := color.New(color.FgBlue).FprintfFunc()
green := color.New(color.FgGreen).FprintfFunc() green := color.New(color.FgGreen).FprintfFunc()
cyan := color.New(color.FgCyan).FprintfFunc() cyan := color.New(color.FgCyan).FprintfFunc()
...@@ -86,7 +81,7 @@ func (f formatterConsole) Format(entry Entry) []byte { ...@@ -86,7 +81,7 @@ func (f formatterConsole) Format(entry Entry) []byte {
cyan(buffer, fmt.Sprintf(" %-40.40s| ", source)) cyan(buffer, fmt.Sprintf(" %-40.40s| ", source))
base := color.New(fgColors[colorNames[f.fg]], bgColors[colorNames[f.bg]]).FprintfFunc() 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 { if len(entry.Data) > 0 {
jsonData, _ := json.Marshal(entry.Data) jsonData, _ := json.Marshal(entry.Data)
...@@ -141,10 +136,6 @@ func (f formatterConsole) NextColor() IFormatter { ...@@ -141,10 +136,6 @@ func (f formatterConsole) NextColor() IFormatter {
nextFg++ nextFg++
if nextFg >= len(fgColors) { if nextFg >= len(fgColors) {
nextFg = 0 nextFg = 0
// nextBg++
// if nextBg >= len(bgColors) {
// nextBg++
// }
} }
if nextFg != nextBg { if nextFg != nextBg {
break break
...@@ -156,6 +147,5 @@ func (f formatterConsole) NextColor() IFormatter { ...@@ -156,6 +147,5 @@ func (f formatterConsole) NextColor() IFormatter {
fg: nextFg, fg: nextFg,
bg: nextBg, bg: nextBg,
} }
//globalLogger.Debugf("NextColor return id=%d Color %s on %s", f.id, colorNames[f.fg], colorNames[f.bg])
return f return f
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment