////////////////////////////////////////////////////////////////////////// Parse a log buffer
| 1251 | /////////////////////////////////////////////////////////////////////////////// |
| 1252 | // Parse a log buffer |
| 1253 | int |
| 1254 | parse_log_buff(LogBufferHeader *buf_header, bool summary = false, bool aggregate_per_userid = false) |
| 1255 | { |
| 1256 | static LogFieldList *fieldlist = nullptr; |
| 1257 | |
| 1258 | LogEntryHeader *entry; |
| 1259 | LogBufferIterator buf_iter(buf_header); |
| 1260 | LogField *field = nullptr; |
| 1261 | ParseStates state; |
| 1262 | |
| 1263 | char *read_from; |
| 1264 | char *tok; |
| 1265 | char *ptr; |
| 1266 | int tok_len; |
| 1267 | int flag = 0; // Flag used in state machine to carry "state" forward |
| 1268 | |
| 1269 | // Parsed results |
| 1270 | int http_code = 0, size = 0, result = 0, hier = 0, elapsed = 0; |
| 1271 | bool ipv6 = false; |
| 1272 | OriginStats *o_stats; |
| 1273 | HTTPMethod method; |
| 1274 | URLScheme scheme; |
| 1275 | |
| 1276 | if (!fieldlist) { |
| 1277 | fieldlist = new LogFieldList; |
| 1278 | ink_assert(fieldlist != nullptr); |
| 1279 | bool agg = false; |
| 1280 | LogFormat::parse_symbol_string(buf_header->fmt_fieldlist(), fieldlist, &agg); |
| 1281 | } |
| 1282 | |
| 1283 | if (!cl.no_format_check) { |
| 1284 | // Validate the fieldlist |
| 1285 | field = fieldlist->first(); |
| 1286 | const std::string_view test_fields[] = {"cqtq", "ttms", "chi", "crc", "pssc", "psql", "cqhm", "pquc", "caun", "phr", "shn"}; |
| 1287 | for (auto &i : test_fields) { |
| 1288 | if (i != field->symbol()) { |
| 1289 | cerr << "Error parsing log file - expected field: " << i << ", but read field: " << field->symbol() << endl; |
| 1290 | return 1; |
| 1291 | } |
| 1292 | field = fieldlist->next(field); |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | // Loop over all entries |
| 1297 | while ((entry = buf_iter.next())) { |
| 1298 | read_from = (char *)entry + sizeof(LogEntryHeader); |
| 1299 | // We read and skip over the first field, which is the timestamp. |
| 1300 | if ((field = fieldlist->first())) { |
| 1301 | read_from += INK_MIN_ALIGN; |
| 1302 | } else { // This shouldn't happen, buffer must be messed up. |
| 1303 | break; |
| 1304 | } |
| 1305 | |
| 1306 | state = P_STATE_ELAPSED; |
| 1307 | o_stats = nullptr; |
| 1308 | method = METHOD_OTHER; |
| 1309 | scheme = SCHEME_OTHER; |
| 1310 |
no test coverage detected