log_entry.go 765 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 index := range v.Values {
  18. v.Values[index] = nil
  19. }
  20. v.Values = nil
  21. }
  22. func (v *ErrorLog) String() string {
  23. return v.Prefix + serial.Concat(v.Values...)
  24. }
  25. type AccessLog struct {
  26. From interface{}
  27. To interface{}
  28. Status string
  29. Reason interface{}
  30. }
  31. func (v *AccessLog) Release() {
  32. v.From = nil
  33. v.To = nil
  34. v.Reason = nil
  35. }
  36. func (v *AccessLog) String() string {
  37. return strings.Join([]string{serial.ToString(v.From), v.Status, serial.ToString(v.To), serial.ToString(v.Reason)}, " ")
  38. }