constants.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package srslog
  2. import (
  3. "errors"
  4. )
  5. // Priority is a combination of the syslog facility and
  6. // severity. For example, LOG_ALERT | LOG_FTP sends an alert severity
  7. // message from the FTP facility. The default severity is LOG_EMERG;
  8. // the default facility is LOG_KERN.
  9. type Priority int
  10. const severityMask = 0x07
  11. const facilityMask = 0xf8
  12. const (
  13. // Severity.
  14. // From /usr/include/sys/syslog.h.
  15. // These are the same on Linux, BSD, and OS X.
  16. LOG_EMERG Priority = iota
  17. LOG_ALERT
  18. LOG_CRIT
  19. LOG_ERR
  20. LOG_WARNING
  21. LOG_NOTICE
  22. LOG_INFO
  23. LOG_DEBUG
  24. )
  25. const (
  26. // Facility.
  27. // From /usr/include/sys/syslog.h.
  28. // These are the same up to LOG_FTP on Linux, BSD, and OS X.
  29. LOG_KERN Priority = iota << 3
  30. LOG_USER
  31. LOG_MAIL
  32. LOG_DAEMON
  33. LOG_AUTH
  34. LOG_SYSLOG
  35. LOG_LPR
  36. LOG_NEWS
  37. LOG_UUCP
  38. LOG_CRON
  39. LOG_AUTHPRIV
  40. LOG_FTP
  41. _ // unused
  42. _ // unused
  43. _ // unused
  44. _ // unused
  45. LOG_LOCAL0
  46. LOG_LOCAL1
  47. LOG_LOCAL2
  48. LOG_LOCAL3
  49. LOG_LOCAL4
  50. LOG_LOCAL5
  51. LOG_LOCAL6
  52. LOG_LOCAL7
  53. )
  54. func validatePriority(p Priority) error {
  55. if p < 0 || p > LOG_LOCAL7|LOG_DEBUG {
  56. return errors.New("log/syslog: invalid priority")
  57. } else {
  58. return nil
  59. }
  60. }