MCPcopy Create free account
hub / github.com/apache/trafficserver / parse_log_buff

Function parse_log_buff

src/traffic_logstats/logstats.cc:1253–1764  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Parse a log buffer

Source from the content-addressed store, hash-verified

1251///////////////////////////////////////////////////////////////////////////////
1252// Parse a log buffer
1253int
1254parse_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

Callers 1

process_fileFunction · 0.85

Calls 9

find_or_create_statsFunction · 0.85
update_statsFunction · 0.85
update_counterFunction · 0.85
strcmpFunction · 0.85
fmt_fieldlistMethod · 0.80
add_statMethod · 0.80
firstMethod · 0.45
symbolMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected