| 567 | } |
| 568 | |
| 569 | int |
| 570 | LogFile::write_ascii_logbuffer3(LogBufferHeader *buffer_header, const char *alt_format) |
| 571 | { |
| 572 | Dbg(dbg_ctl_log_file, |
| 573 | "entering LogFile::write_ascii_logbuffer3 for %s " |
| 574 | "(this=%p)", |
| 575 | m_name, this); |
| 576 | ink_assert(buffer_header != nullptr); |
| 577 | |
| 578 | LogBufferIterator iter(buffer_header); |
| 579 | LogEntryHeader *entry_header; |
| 580 | int fmt_entry_count = 0; |
| 581 | int fmt_buf_bytes = 0; |
| 582 | int total_bytes = 0; |
| 583 | |
| 584 | LogFormatType format_type; |
| 585 | char *fieldlist_str; |
| 586 | char *printf_str; |
| 587 | char *ascii_buffer; |
| 588 | |
| 589 | switch (buffer_header->version) { |
| 590 | case LOG_SEGMENT_VERSION: |
| 591 | format_type = static_cast<LogFormatType>(buffer_header->format_type); |
| 592 | fieldlist_str = buffer_header->fmt_fieldlist(); |
| 593 | printf_str = buffer_header->fmt_printf(); |
| 594 | break; |
| 595 | |
| 596 | default: |
| 597 | Note("Invalid LogBuffer version %d in write_ascii_logbuffer; " |
| 598 | "current version is %d", |
| 599 | buffer_header->version, LOG_SEGMENT_VERSION); |
| 600 | return 0; |
| 601 | } |
| 602 | |
| 603 | while ((entry_header = iter.next())) { |
| 604 | fmt_entry_count = 0; |
| 605 | fmt_buf_bytes = 0; |
| 606 | |
| 607 | if (m_file_format == LOG_FILE_PIPE) { |
| 608 | ascii_buffer = static_cast<char *>(ats_malloc(m_max_line_size)); |
| 609 | } else { |
| 610 | ascii_buffer = static_cast<char *>(ats_malloc(m_ascii_buffer_size)); |
| 611 | } |
| 612 | |
| 613 | // fill the buffer with as many records as possible |
| 614 | // |
| 615 | do { |
| 616 | if (entry_header->entry_len >= m_max_line_size) { |
| 617 | Warning("Log is too long(%" PRIu32 "), it would be truncated. max_len:%zu", entry_header->entry_len, m_max_line_size); |
| 618 | } |
| 619 | |
| 620 | int bytes = LogBuffer::to_ascii(entry_header, format_type, &ascii_buffer[fmt_buf_bytes], m_max_line_size - 1, fieldlist_str, |
| 621 | printf_str, buffer_header->version, alt_format, get_escape_type()); |
| 622 | |
| 623 | if (bytes > 0) { |
| 624 | fmt_buf_bytes += bytes; |
| 625 | ascii_buffer[fmt_buf_bytes] = '\n'; |
| 626 | ++fmt_buf_bytes; |
nothing calls this directly
no test coverage detected