log.go 515 B

12345678910111213141516171819202122232425262728293031323334
  1. package grocery
  2. type level int
  3. const (
  4. FINEST level = iota
  5. FINE
  6. DEBUG
  7. TRACE
  8. INFO
  9. WARNING
  10. ERROR
  11. CRITICAL
  12. )
  13. var (
  14. kLevelStrings = [...]string{"FINEST", "FINE", "DEBUG", "TRACE", "INFO", "WARNING", "ERROR", "CRITICAL"}
  15. )
  16. func (l level) String() string {
  17. if l < 0 || int(l) > len(kLevelStrings) {
  18. return "UNKNOWN"
  19. }
  20. return kLevelStrings[int(l)]
  21. }
  22. type LogRecord struct {
  23. Level level // The log level
  24. Message string // The log message
  25. }
  26. func (r *LogRecord) String() string {
  27. return r.Message
  28. }