trace.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2021 IBM Corp and others.
  3. *
  4. * All rights reserved. This program and the accompanying materials
  5. * are made available under the terms of the Eclipse Public License v2.0
  6. * and Eclipse Distribution License v1.0 which accompany this distribution.
  7. *
  8. * The Eclipse Public License is available at
  9. * https://www.eclipse.org/legal/epl-2.0/
  10. * and the Eclipse Distribution License is available at
  11. * http://www.eclipse.org/org/documents/edl-v10.php.
  12. *
  13. * Contributors:
  14. * Seth Hoenig
  15. * Allan Stockdill-Mander
  16. * Mike Robertson
  17. */
  18. package mqtt
  19. type (
  20. // Logger interface allows implementations to provide to this package any
  21. // object that implements the methods defined in it.
  22. Logger interface {
  23. Println(v ...interface{})
  24. Printf(format string, v ...interface{})
  25. }
  26. // NOOPLogger implements the logger that does not perform any operation
  27. // by default. This allows us to efficiently discard the unwanted messages.
  28. NOOPLogger struct{}
  29. )
  30. func (NOOPLogger) Println(v ...interface{}) {}
  31. func (NOOPLogger) Printf(format string, v ...interface{}) {}
  32. // Internal levels of library output that are initialised to not print
  33. // anything but can be overridden by programmer
  34. var (
  35. ERROR Logger = NOOPLogger{}
  36. CRITICAL Logger = NOOPLogger{}
  37. WARN Logger = NOOPLogger{}
  38. DEBUG Logger = NOOPLogger{}
  39. )