log_entry.go 778 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package internal
  2. import (
  3. "fmt"
  4. "strings"
  5. "v2ray.com/core/common"
  6. "v2ray.com/core/common/serial"
  7. )
  8. type LogEntry interface {
  9. common.Releasable
  10. fmt.Stringer
  11. }
  12. type ErrorLog struct {
  13. Prefix string
  14. Values []interface{}
  15. }
  16. func (v *ErrorLog) Release() {
  17. for _, val := range v.Values {
  18. common.Release(val)
  19. }
  20. }
  21. func (v *ErrorLog) String() string {
  22. return v.Prefix + serial.Concat(v.Values...)
  23. }
  24. type AccessLog struct {
  25. From interface{}
  26. To interface{}
  27. Status string
  28. Reason interface{}
  29. }
  30. func (v *AccessLog) Release() {
  31. common.Release(v.From)
  32. common.Release(v.To)
  33. common.Release(v.Reason)
  34. }
  35. func (v *AccessLog) String() string {
  36. return strings.Join([]string{serial.ToString(v.From), v.Status, serial.ToString(v.To), serial.ToString(v.Reason)}, " ")
  37. }