117 template <
typename T>
132 return maxFilenameNumber;
138 static std::string getFileName(
int logNumber);
140 static void packThreadLauncher(
void* argv);
142 static void writeThreadLauncher(
void* argv);
161 LoggerResult logImpl(
const char* name,
const void* data,
unsigned int size);
163 static constexpr unsigned int maxFilenameNumber =
165#ifndef _ARCH_CORTEXM3_STM32F2
166 static constexpr unsigned int maxRecordSize = 512;
167 static constexpr unsigned int numRecords = 512;
168 static constexpr unsigned int numBuffers = 8;
169 static constexpr unsigned int bufferSize = 64 * 1024;
171 static constexpr unsigned int maxRecordSize = 512;
172 static constexpr unsigned int numRecords = 64;
173 static constexpr unsigned int numBuffers = 8;
174 static constexpr unsigned int bufferSize = 4 * 1024;
186 Record() : size(0) {}
187 char data[maxRecordSize] = {};
200 Buffer() : size(0) {}
201 char data[bufferSize] = {};
207 miosix::Queue<Record*, numRecords> fullRecordsQueue;
208 miosix::Queue<Record*, numRecords> emptyRecordsQueue;
209 std::queue<Buffer*, std::list<Buffer*>> fullBufferList;
210 std::queue<Buffer*, std::list<Buffer*>> emptyBufferList;
211 miosix::FastMutex mutex;
212 miosix::ConditionVariable cond;
214 miosix::Thread* packTh =
nullptr;
215 miosix::Thread* writeTh =
nullptr;
217 volatile bool started =
false;
219 FILE* file =
nullptr;
227 std::is_trivially_copyable<T>::value,
228 "The type T must be trivially copyable in order to be logged!");
230 return logImpl(
typeid(t).name(), &t,
sizeof(t));
Buffered logger. Needs to be started before it can be used.
LoggerResult log(const T &t)
Call this function to log a class.
void logStats()
Log logger stats using the logger itself.
std::string getCurrentFileName()
static constexpr unsigned int getMaxFilenameNumber()
Returns the Max Filename number.
int getCurrentLogNumber()
static bool testSDCard()
Tests if the Logger can write to the SD card by opening a file.
void stop()
Call this function to stop the logger.
bool start()
Call this function to start the logger.
This file includes all the types the logdecoder script will decode.
LoggerResult
Possible outcomes of Logger::log().
@ Dropped
Buffers are currently full, data will not be written. Sorry.
@ Queued
Data has been accepted by the logger and will be written.
@ TooLarge
Data is too large to be logged. Increase maxRecordSize.
@ Ignored
Logger is currently stopped, data will not be written.
Statistics for the logger.