log.go 473 B

123456789101112131415161718192021222324252627282930
  1. package mssql
  2. import (
  3. "log"
  4. )
  5. type Logger interface {
  6. Printf(format string, v ...interface{})
  7. Println(v ...interface{})
  8. }
  9. type optionalLogger struct {
  10. logger Logger
  11. }
  12. func (o optionalLogger) Printf(format string, v ...interface{}) {
  13. if o.logger != nil {
  14. o.logger.Printf(format, v...)
  15. } else {
  16. log.Printf(format, v...)
  17. }
  18. }
  19. func (o optionalLogger) Println(v ...interface{}) {
  20. if o.logger != nil {
  21. o.logger.Println(v...)
  22. } else {
  23. log.Println(v...)
  24. }
  25. }