s_debug.go 541 B

12345678910111213141516171819202122232425262728293031
  1. package backends
  2. import (
  3. "fmt"
  4. "github.com/flashmob/go-guerrilla/mail"
  5. )
  6. func init() {
  7. streamers["debug"] = func() *StreamDecorator {
  8. return StreamDebug()
  9. }
  10. }
  11. func StreamDebug() *StreamDecorator {
  12. sd := &StreamDecorator{}
  13. sd.p =
  14. func(sp StreamProcessor) StreamProcessor {
  15. sd.Open = func(e *mail.Envelope) error {
  16. return nil
  17. }
  18. return StreamProcessWith(func(p []byte) (int, error) {
  19. fmt.Println(string(p))
  20. Log().WithField("p", string(p)).Info("Debug stream")
  21. return sp.Write(p)
  22. })
  23. }
  24. return sd
  25. }