Add postgres format logs#5
Conversation
| } | ||
| } | ||
|
|
||
| func TestLogger_PrintWithTextWriter(t *testing.T) { |
There was a problem hiding this comment.
Many tests with only little details different, extract the separate function with common code and provide the input / expected output.
| fieldValues FieldValues | ||
| } | ||
|
|
||
| func NewLogger(fieldValues FieldValues, loggerWriters ...LoggerWriter) *Logger { |
There was a problem hiding this comment.
We don't need many writers at the same time, so I suggest to change it to a single writer for simplicity.
| "time" | ||
| ) | ||
|
|
||
| type PostgresLogger struct { |
There was a problem hiding this comment.
Why we need separate struct for pg logger? Can we just provide the correct writer to the constructor of the main one?
| } | ||
|
|
||
| func setupWalgLoggers() { | ||
| if logLevel == NormalLogLevel { |
There was a problem hiding this comment.
the only difference is the destinations for debug/info/error loggers, other code must not be duplicated.
| var ErrorPostgresLogger = NewLogger(GetFieldValues(ErrorLoggerType), NewTextWriter(os.Stderr, BasicFormat, BasicFields)) | ||
| var DebugPostgresLogger = NewLogger(GetFieldValues(DebugLoggerType), NewTextWriter(ioutil.Discard, BasicFormat, BasicFields)) | ||
| func setupJsonPgLoggers() { | ||
| if logLevel == NormalLogLevel { |
| if logWriter == TextWalg { | ||
| setupWalgLoggers() | ||
| } else if logWriter == JsonPg { | ||
| setupJsonPgLoggers() |
There was a problem hiding this comment.
why need to use separate functions? Can we just setup the writer and field values and then send it to setupLoggers()?
Issue