25 #ifndef LOG4CPP_HEXLOGGING_H 26 #define LOG4CPP_HEXLOGGING_H 28 #include "ser4cpp/container/SequenceTypes.h" 29 #include "ser4cpp/util/HexConversions.h" 30 #include "ser4cpp/util/Uncopyable.h" 32 #include "log4cpp/Location.h" 33 #include "log4cpp/Logger.h" 40 static const uint32_t max_hex_per_line = max_log_entry_size / 3;
48 uint32_t first_row_size = max_hex_per_line,
49 uint32_t other_row_size = max_hex_per_line
55 const auto max_first_size = ser4cpp::bounded<uint32_t>(first_row_size, 1, max_hex_per_line);
56 const auto max_other_size = ser4cpp::bounded<uint32_t>(other_row_size, 1, max_hex_per_line);
58 while (copy.is_not_empty())
60 const auto row_size = (row == 0) ? max_first_size : max_other_size;
61 copy = log_line(logger, level, copy, separator, row_size);
75 char buffer[max_log_entry_size];
79 while ((count < max_row_size) && (count < data.length()))
82 buffer[pos] = ser4cpp::HexConversions::to_hex_char((data[count] & 0xF0) >> 4);
83 buffer[pos + 1] = ser4cpp::HexConversions::to_hex_char(data[count] & 0x0F);
84 buffer[pos + 2] = separator;
88 buffer[(3 * count) - 1] =
'\0';
90 logger.log(level, LOCATION, buffer);
92 return data.skip(count);
98 #endif //LOG4CPP_HEXLOGGING_H
log4cpp header-only library namespace