-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusptgo.go
30 lines (22 loc) · 850 Bytes
/
usptgo.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
30
package usptgo
import (
"github.com/diverged/uspt-go/internal"
"github.com/diverged/uspt-go/types"
)
// USPTGo accepts a USPTGoConfig and returns one USPTGoDoc channel and one USPTGoError channel
func USPTGo(cfg *types.USPTGoConfig) (<-chan *types.USPTGoDoc, <-chan error, error) {
// Defaults to a no-op logger which does nothing with log messages
if cfg.Logger == nil {
cfg.Logger = noOpLogger{}
}
docChan, errChan, err := internal.Dispatcher(cfg)
if err != nil {
return nil, nil, err
}
return docChan, errChan, nil
}
type noOpLogger struct{}
func (l noOpLogger) Debug(msg string, keysAndValues ...interface{}) {}
func (l noOpLogger) Info(msg string, keysAndValues ...interface{}) {}
func (l noOpLogger) Warn(msg string, keysAndValues ...interface{}) {}
func (l noOpLogger) Error(msg string, keysAndValues ...interface{}) {}