logger.go 989 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package sizer
  2. import "log"
  3. // Debug is a global bool to toggle debugging messages.
  4. var Debug bool
  5. type console log.Logger
  6. func (l *console) SetFlags(i int) {
  7. log.SetFlags(i)
  8. }
  9. func (l *console) Print(v ...interface{}) {
  10. log.Print(v...)
  11. }
  12. func (l *console) Printf(format string, v ...interface{}) {
  13. log.Printf(format, v...)
  14. }
  15. func (l *console) Println(v ...interface{}) {
  16. log.Println(v...)
  17. }
  18. func (l *console) Fatal(v ...interface{}) {
  19. log.Fatal(v...)
  20. }
  21. func (l *console) Fatalf(format string, v ...interface{}) {
  22. log.Fatalf(format, v...)
  23. }
  24. func (l *console) Fatalln(v ...interface{}) {
  25. log.Fatalln(v...)
  26. }
  27. func (l *console) Debug(msg ...interface{}) {
  28. if Debug {
  29. l.Print(msg...)
  30. }
  31. }
  32. func (l *console) Debugf(format string, msg ...interface{}) {
  33. if Debug {
  34. l.Printf(format, msg...)
  35. }
  36. }
  37. func (l *console) Debugln(msg ...interface{}) {
  38. if Debug {
  39. l.Println(msg...)
  40. }
  41. }
  42. // Console is the logger object
  43. var Console console
  44. func init() {
  45. Console.SetFlags(0)
  46. }