nginx_access_log_test.go 859 B

1234567891011121314
  1. package po
  2. import (
  3. "encoding/json"
  4. "testing"
  5. )
  6. func TestNginxAccessLog_FixFields(t *testing.T) {
  7. arg := &NginxAccessLog{}
  8. line := `{"time_local": "2025-01-09T10:47:57+08:00", "remote_addr": "205.210.31.222", "referer": "-", "request": "\x16\x03\x01\x00\xEE\x01\x00\x00\xEA\x03\x03\x1C\xCD.\xCD\x04\xDF*\xD0\xFE\xD3&\xE5\x08.\x05\xFB\x80W\x129=\x91\x1F1\xECv\xE9\xF8D\xEA\xAA\xE8 \x92*}b\xBEA\x7F\x95I\x0B\x15\xEA\xB3\xBD\xD4\x8A\xC02o%wB\xA60Bf\xAAI\xCB\xAA\xE3|\x00&\xC0+\xC0/\xC0,\xC00\xCC\xA9\xCC\xA8\xC0\x09\xC0\x13\xC0", "status": 400, "body_bytes_sent": "173", "agent": "-", "x_forwarded": "-", "up_addr": "-","up_host": "-","up_resp_time": "-","request_time": "5.000", "request_length": "0", "request_id": "0fa54deb2fd2190b9f66b2f4b53cf66c", "host": "_" }`
  9. if err := json.Unmarshal([]byte(line), arg); err != nil {
  10. t.Errorf(err.Error())
  11. }
  12. }