debug.go 547 B

123456789101112131415161718192021222324252627282930
  1. package ldap
  2. import (
  3. "log"
  4. ber "github.com/go-asn1-ber/asn1-ber"
  5. )
  6. // debugging type
  7. // - has a Printf method to write the debug output
  8. type debugging bool
  9. // Enable controls debugging mode.
  10. func (debug *debugging) Enable(b bool) {
  11. *debug = debugging(b)
  12. }
  13. // Printf writes debug output.
  14. func (debug debugging) Printf(format string, args ...interface{}) {
  15. if debug {
  16. log.Printf(format, args...)
  17. }
  18. }
  19. // PrintPacket dumps a packet.
  20. func (debug debugging) PrintPacket(packet *ber.Packet) {
  21. if debug {
  22. ber.PrintPacket(packet)
  23. }
  24. }