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

Method resolve_custom_entry

src/proxy/logging/LogBuffer.cc:484–581  ·  view source on GitHub ↗

------------------------------------------------------------------------- LogBuffer::resolve_custom_entry -------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

482 LogBuffer::resolve_custom_entry
483 -------------------------------------------------------------------------*/
484int
485LogBuffer::resolve_custom_entry(LogFieldList *fieldlist, char *printf_str, char *read_from, char *write_to, int write_to_len,
486 long /* timestamp ATS_UNUSED */, long /* timestamp_usec ATS_UNUSED */,
487 unsigned /* buffer_version ATS_UNUSED */, LogFieldList *alt_fieldlist, char *alt_printf_str,
488 LogEscapeType escape_type)
489{
490 if (fieldlist == nullptr || printf_str == nullptr) {
491 return 0;
492 }
493
494 int *readfrom_map = nullptr;
495
496 if (alt_fieldlist && alt_printf_str) {
497 LogField *f, *g;
498 int n_alt_fields = alt_fieldlist->count();
499 int i = 0;
500
501 readfrom_map = static_cast<int *>(ats_malloc(n_alt_fields * sizeof(int)));
502 for (f = alt_fieldlist->first(); f; f = alt_fieldlist->next(f)) {
503 int readfrom_pos = 0;
504 bool found_match = false;
505 for (g = fieldlist->first(); g; g = fieldlist->next(g)) {
506 if (strcmp(f->symbol(), g->symbol()) == 0) {
507 found_match = true;
508 readfrom_map[i++] = readfrom_pos;
509 break;
510 }
511 // TODO handle readfrom_pos properly
512 // readfrom_pos += g->size();
513 }
514 if (!found_match) {
515 Note("Alternate format contains a field (%s) not in the "
516 "format logged",
517 f->symbol());
518 break;
519 }
520 }
521 }
522 //
523 // Loop over the printf_str, copying everything to the write_to buffer
524 // except the LOG_FIELD_MARKER characters. When we reach those, we
525 // substitute the string from the unmarshal routine of the current
526 // LogField object, obtained from the fieldlist.
527 //
528
529 LogField *field = fieldlist->first();
530 LogField *lastField = nullptr; // For debug message.
531 int markCount = 0; // For debug message.
532 int printf_len = static_cast<int>(::strlen(printf_str)); // OPTIMIZE
533 int bytes_written = 0;
534 int res, i;
535
536 const char *buffer_size_exceeded_msg = "Traffic Server is skipping the current log entry because its size "
537 "exceeds the maximum line (entry) size for an ascii log buffer";
538
539 for (i = 0; i < printf_len; i++) {
540 if (printf_str[i] == LOG_FIELD_MARKER) {
541 ++markCount;

Callers

nothing calls this directly

Calls 12

ats_mallocFunction · 0.85
strcmpFunction · 0.85
ats_freeFunction · 0.85
badSymbolsMethod · 0.80
countMethod · 0.45
firstMethod · 0.45
nextMethod · 0.45
symbolMethod · 0.45
unmarshalMethod · 0.45
sizeMethod · 0.45
printMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected