-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented new logging system (#562)
* Implemented new logging system for resty migration * Address PR Comments * Moved template creation and parsing to top level vars * Cleaned up doRequest and broke it up into helpers * Addressed more PR comments
- Loading branch information
1 parent
a9e3be2
commit 8f07a76
Showing
4 changed files
with
302 additions
and
20 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package linodego | ||
|
||
import ( | ||
"log" | ||
"os" | ||
) | ||
|
||
//nolint:unused | ||
type httpLogger interface { | ||
Errorf(format string, v ...interface{}) | ||
Warnf(format string, v ...interface{}) | ||
Debugf(format string, v ...interface{}) | ||
} | ||
|
||
//nolint:unused | ||
type logger struct { | ||
l *log.Logger | ||
} | ||
|
||
//nolint:unused | ||
func createLogger() *logger { | ||
l := &logger{l: log.New(os.Stderr, "", log.Ldate|log.Lmicroseconds)} | ||
return l | ||
} | ||
|
||
//nolint:unused | ||
var _ httpLogger = (*logger)(nil) | ||
|
||
//nolint:unused | ||
func (l *logger) Errorf(format string, v ...interface{}) { | ||
l.output("ERROR RESTY "+format, v...) | ||
} | ||
|
||
//nolint:unused | ||
func (l *logger) Warnf(format string, v ...interface{}) { | ||
l.output("WARN RESTY "+format, v...) | ||
} | ||
|
||
//nolint:unused | ||
func (l *logger) Debugf(format string, v ...interface{}) { | ||
l.output("DEBUG RESTY "+format, v...) | ||
} | ||
|
||
//nolint:unused | ||
func (l *logger) output(format string, v ...interface{}) { //nolint:goprintffuncname | ||
if len(v) == 0 { | ||
l.l.Print(format) | ||
return | ||
} | ||
l.l.Printf(format, v...) | ||
} |