-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from pierresouchay/use_interface_for_logger
Use interface to log in Consul package
- Loading branch information
Showing
6 changed files
with
92 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package consul | ||
|
||
// Logger Allows replacing easily the logger. | ||
type Logger interface { | ||
// Debugf Display debug message | ||
Debugf(format string, args ...interface{}) | ||
// Infof Display info message | ||
Infof(format string, args ...interface{}) | ||
// Warnf Display warning message | ||
Warnf(format string, args ...interface{}) | ||
// Errorf Display error message | ||
Errorf(format string, args ...interface{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package consul | ||
|
||
import "testing" | ||
|
||
type testingLogger struct { | ||
t *testing.T | ||
} | ||
|
||
// Debugf Display debug message | ||
func (l *testingLogger) Debugf(format string, args ...interface{}) { | ||
l.t.Logf(format, args...) | ||
} | ||
|
||
// Infof Display info message | ||
func (l *testingLogger) Infof(format string, args ...interface{}) { | ||
l.t.Logf(format, args...) | ||
} | ||
|
||
// Warnf Display warning message | ||
func (l *testingLogger) Warnf(format string, args ...interface{}) { | ||
l.t.Logf(format, args...) | ||
} | ||
|
||
// Errorf Display error message | ||
func (l *testingLogger) Errorf(format string, args ...interface{}) { | ||
l.t.Logf(format, args...) | ||
} | ||
|
||
// NewTestingLogger creates a Logger for testing.T | ||
func NewTestingLogger(t *testing.T) Logger { | ||
return &testingLogger{t: t} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters