Skip to content
Snippets Groups Projects
Commit 8183e4fb authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

logfields for golang logger

parent a8267e8b
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ const (
)
type Logger interface {
WithFields(args map[string]interface{}) Logger
Info(args ...interface{})
Debug(args ...interface{})
Fatal(args ...interface{})
......
......@@ -13,6 +13,13 @@ func (l *logRusLogger) SetSource(source string) {
l.source = source
}
func (l *logRusLogger) WithFields(args map[string]interface{}) Logger {
l.logger_entry = l.entry().WithFields(args)
return l
}
func (l *logRusLogger) entry() *log.Entry {
if l.logger_entry != nil {
return l.logger_entry
......
......@@ -16,6 +16,11 @@ func SetMockLog() {
my_logger = &MockLog
}
func (l *MockLogger) WithFields(args map[string]interface{}) Logger {
l.Called(args)
return l
}
func UnsetMockLog() {
my_logger = &logRusLogger{}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment