高热共公日志库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.7 KiB

  1. package grlogs
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. )
  6. type ConsoleLogConfig struct {
  7. Level Level `json:"level"`
  8. }
  9. func (c *ConsoleLogConfig) String() string {
  10. b, _ := json.Marshal(c)
  11. return bytes.NewBuffer(b).String()
  12. }
  13. type FileLogConfig struct {
  14. Filename string `json:"filename"`
  15. Level Level `json:"level"`
  16. Maxlines int `json:"maxlines"`
  17. Daily bool `json:"daily"`
  18. Maxdays int `json:"maxdays"`
  19. Color bool `json:"color"`
  20. Rotate bool `json:"rotate"`
  21. }
  22. func (c *FileLogConfig) String() string {
  23. b, _ := json.Marshal(c)
  24. return bytes.NewBuffer(b).String()
  25. }
  26. type ConnLogConfig struct {
  27. ReconnectOnMsg bool `json:"reconnect_on_msg"`
  28. Reconnect bool `json:"reconnect"`
  29. Net string `json:"net"`
  30. Addr string `json:"addr"`
  31. Level Level `json:"level"`
  32. }
  33. func (c *ConnLogConfig) String() string {
  34. b, _ := json.Marshal(c)
  35. return bytes.NewBuffer(b).String()
  36. }
  37. type EsConfig struct {
  38. Username string `json:"username"`
  39. Password string `json:"password"`
  40. Dsn string `json:"dsn"`
  41. Level Level `json:"level"`
  42. Index string `json:"index"`
  43. }
  44. func (c *EsConfig) String() string {
  45. b, _ := json.Marshal(c)
  46. return bytes.NewBuffer(b).String()
  47. }
  48. type AliLSConfig struct {
  49. Project string `json:"project"`
  50. Endpoint string `json:"endpoint"`
  51. KeyID string `json:"key_id"`
  52. KeySecret string `json:"key_secret"`
  53. LogStore string `json:"log_store"`
  54. Topics []string `json:"topics"`
  55. Source string `json:"source"`
  56. Level Level `json:"level"`
  57. FlushWhen int `json:"flush_when"`
  58. }
  59. func (c *AliLSConfig) String() string {
  60. b, _ := json.Marshal(c)
  61. return bytes.NewBuffer(b).String()
  62. }