2020-11-15 14:05:51 +00:00
|
|
|
#include "NrfLogger.h"
|
|
|
|
|
|
|
|
#include <libraries/log/nrf_log.h>
|
2019-11-17 19:47:04 +00:00
|
|
|
#include <libraries/log/nrf_log_ctrl.h>
|
|
|
|
#include <libraries/log/nrf_log_default_backends.h>
|
|
|
|
|
|
|
|
using namespace Pinetime::Logging;
|
|
|
|
|
|
|
|
void NrfLogger::Init() {
|
|
|
|
auto result = NRF_LOG_INIT(nullptr);
|
|
|
|
APP_ERROR_CHECK(result);
|
|
|
|
|
|
|
|
NRF_LOG_DEFAULT_BACKENDS_INIT();
|
|
|
|
|
2021-05-14 09:43:29 +00:00
|
|
|
if (pdPASS != xTaskCreate(NrfLogger::Process, "LOGGER", 200, this, 0, &m_logger_thread)) {
|
2019-11-17 19:47:04 +00:00
|
|
|
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
|
2021-05-14 09:43:29 +00:00
|
|
|
}
|
2019-11-17 19:47:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NrfLogger::Process(void*) {
|
|
|
|
NRF_LOG_INFO("Logger task started!");
|
2021-04-18 17:28:14 +00:00
|
|
|
// Suppress endless loop diagnostic
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma ide diagnostic ignored "EndlessLoop"
|
2021-05-14 09:40:46 +00:00
|
|
|
while (true) {
|
2019-11-17 19:47:04 +00:00
|
|
|
NRF_LOG_FLUSH();
|
2020-01-05 10:09:07 +00:00
|
|
|
vTaskDelay(100); // Not good for power consumption, it will wake up every 100ms...
|
2019-11-17 19:47:04 +00:00
|
|
|
}
|
2021-04-18 17:28:14 +00:00
|
|
|
// Clear diagnostic suppression
|
|
|
|
#pragma clang diagnostic pop
|
2019-11-17 19:47:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NrfLogger::Resume() {
|
|
|
|
vTaskResume(m_logger_thread);
|
|
|
|
}
|