forked from jjeffery/stomp
-
Notifications
You must be signed in to change notification settings - Fork 96
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 #108 from codemedic/customisable-logger
Make it possible to set logger
- Loading branch information
Showing
9 changed files
with
116 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package log | ||
|
||
import ( | ||
"fmt" | ||
stdlog "log" | ||
) | ||
|
||
var ( | ||
debugPrefix = "DEBUG: " | ||
infoPrefix = "INFO: " | ||
warnPrefix = "WARN: " | ||
errorPrefix = "ERROR: " | ||
) | ||
|
||
func logf(prefix string, format string, value ...interface{}) { | ||
_ = stdlog.Output(3, fmt.Sprintf(prefix+format+"\n", value...)) | ||
} | ||
|
||
type StdLogger struct{} | ||
|
||
func (s StdLogger) Debugf(format string, value ...interface{}) { | ||
logf(debugPrefix, format, value...) | ||
} | ||
|
||
func (s StdLogger) Debug(message string) { | ||
logf(debugPrefix, "%s", message) | ||
} | ||
|
||
func (s StdLogger) Infof(format string, value ...interface{}) { | ||
logf(infoPrefix, format, value...) | ||
} | ||
|
||
func (s StdLogger) Info(message string) { | ||
logf(infoPrefix, "%s", message) | ||
} | ||
|
||
func (s StdLogger) Warningf(format string, value ...interface{}) { | ||
logf(warnPrefix, format, value...) | ||
} | ||
|
||
func (s StdLogger) Warning(message string) { | ||
logf(warnPrefix, "%s", message) | ||
} | ||
|
||
func (s StdLogger) Errorf(format string, value ...interface{}) { | ||
logf(errorPrefix, format, value...) | ||
} | ||
|
||
func (s StdLogger) Error(message string) { | ||
logf(errorPrefix, "%s", message) | ||
} |
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 stomp | ||
|
||
type Logger interface { | ||
Debugf(format string, value ...interface{}) | ||
Infof(format string, value ...interface{}) | ||
Warningf(format string, value ...interface{}) | ||
Errorf(format string, value ...interface{}) | ||
|
||
Debug(message string) | ||
Info(message string) | ||
Warning(message string) | ||
Error(message string) | ||
} |
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
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