log.go 504 B

12345678910111213141516171819202122232425262728293031
  1. package nginx
  2. import "strings"
  3. // refer to https://nginx.org/en/docs/ngx_core_module.html#error_log
  4. // nginx log level: debug, info, notice, warn, error, crit, alert, or emerg
  5. const (
  6. Unknown = -1
  7. Debug = iota
  8. Info
  9. Notice
  10. Warn
  11. Error
  12. Crit
  13. Alert
  14. Emerg
  15. )
  16. var logLevel = [...]string{
  17. "debug", "info", "notice", "warn", "error", "crit", "alert", "emerg",
  18. }
  19. func GetLogLevel(output string) int {
  20. for k, v := range logLevel {
  21. if strings.Contains(output, v) {
  22. return k
  23. }
  24. }
  25. return -1
  26. }