Skip to content

Commit

Permalink
Formatter does not act on an argument queue but on an argument array
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe Corbelli committed Oct 12, 2017
1 parent cea7b2f commit 4224550
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions include/rtlog/Formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class CFormatterT
fmt::BasicArrayWriter<typename LOGGER_TRAITS::CHAR_TYPE> m_Writer;
/** Formatter buffer */
typename LOGGER_TRAITS::CHAR_TYPE m_Buffer[LOGGER_TRAITS::BUFFER_SIZE];
rtlog::ArgumentArrayT<LOGGER_TRAITS> m_ArgumentArray;
rtlog::Argument m_Argument;

public:
Expand All @@ -35,22 +34,17 @@ class CFormatterT
{ return m_Writer.c_str(); }

/** Performs a single message formatting and return internal pointer */
const char_type* format(moodycamel::ConcurrentQueue<rtlog::ArgumentArrayT<LOGGER_TRAITS>, QUEUE_TRAITS>& queue)
const char_type* format(rtlog::ArgumentArrayT<LOGGER_TRAITS>& argument_array)
{
if (queue.try_dequeue(m_ArgumentArray)) {
// Dequeue a log message block
// It SHOULD be complete but it's not guaranteed
m_Writer.clear();
// TODO: should be writer << argument
for (auto& elem : m_ArgumentArray) {
if (elem.empty())
return NULL; // Encountered an empty element before end marker, message incomplete

m_Writer << elem;

if (Argument::is_type<rtlog::_ArrayEndMarker>(elem))
return m_Writer.c_str(); // End of message found
}
m_Writer.clear();
for (auto& elem : argument_array) {
if (elem.empty())
break; // Encountered an empty element before end marker, message incomplete

m_Writer << elem;

if (Argument::is_type<rtlog::_ArrayEndMarker>(elem))
return m_Writer.c_str(); // End of message found
}
return NULL; // No message enqueued
}
Expand Down

0 comments on commit 4224550

Please sign in to comment.