forked from 0x4b53/amqp-rpc
/
logging.go
29 lines (20 loc) · 808 Bytes
/
logging.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package amqprpc
/*
LogFunc is used for logging in amqp-rpc. It makes it possible to define your own logging.
Here is an example where the logger from the log package is used:
debugLogger := log.New(os.Stdout, "DEBUG - ", log.LstdFlags)
errorLogger := log.New(os.Stdout, "ERROR - ", log.LstdFlags)
server := NewServer(url)
server.WithErrorLogger(errorLogger.Printf)
server.WithDebugLogger(debugLogger.Printf)
It can also be used with for example a Logrus logger:
logger := logrus.New()
logger.SetLevel(logrus.DebugLevel)
logger.Formatter = &logrus.JSONFormatter{}
s.WithErrorLogger(logger.Warnf)
s.WithDebugLogger(logger.Debugf)
client := NewClient(url)
client.WithErrorLogger(logger.Errorf)
client.WithDebugLogger(logger.Debugf)
*/
type LogFunc func(format string, args ...interface{})