Browse Source

Updated logger example

pull/73/head
Anatoly Ibragimov 4 years ago
parent
commit
21618aff63
1 changed files with 15 additions and 3 deletions
  1. +15
    -3
      examples/logger/main.go

+ 15
- 3
examples/logger/main.go View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"log"
rabbitmq "github.com/wagslane/go-rabbitmq"
@ -9,9 +10,20 @@ import (
// customLogger is used in WithPublisherOptionsLogger to create a custom logger.
type customLogger struct{}
// Printf is the only method needed in the Logger interface to function properly.
func (c *customLogger) Printf(fmt string, args ...interface{}) {
log.Printf("mylogger: "+fmt, args...)
func (l *customLogger) Debug(s string) {
log.Println(fmt.Sprintf("[Debug] mylogger: %s", s))
}
func (l *customLogger) Info(s string) {
log.Println(fmt.Sprintf("[Info] mylogger: %s", s))
}
func (l *customLogger) Warning(s string) {
log.Println(fmt.Sprintf("[Warning] mylogger: %s", s))
}
func (l *customLogger) Error(s string) {
log.Println(fmt.Sprintf("[Error] mylogger: %s", s))
}
func main() {


Loading…
Cancel
Save