github.com/jiasir/deis@v1.12.2/logger/drain/factory.go (about) 1 package drain 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/deis/deis/logger/drain/simple" 8 ) 9 10 // NewDrain returns a pointer to an appropriate implementation of the LogDrain interface, as 11 // determined by the drainURL it is passed. 12 func NewDrain(drainURL string) (LogDrain, error) { 13 if drainURL == "" { 14 // nil means no drain-- which is valid 15 return nil, nil 16 } 17 // Any of these three can use the same drain implementation 18 if strings.HasPrefix(drainURL, "udp://") || strings.HasPrefix(drainURL, "syslog://") || strings.HasPrefix(drainURL, "tcp://") { 19 drain, err := simple.NewDrain(drainURL) 20 if err != nil { 21 return nil, err 22 } 23 return drain, nil 24 } 25 // TODO: Add more drain implementations-- TLS over TCP and HTTP/S 26 return nil, fmt.Errorf("Cannot construct a drain for URL: '%s'", drainURL) 27 }