summaryrefslogtreecommitdiff
path: root/src/Logging/NrfLogger.cpp
blob: 0663940109f5750359b5314d3a7eb1f741e9ada3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <libraries/log/nrf_log_ctrl.h>
#include <libraries/log/nrf_log_default_backends.h>
#include <FreeRTOS.h>
#include <task.h>
#include <libraries/log/nrf_log.h>
#include "NrfLogger.h"

using namespace Pinetime::Logging;

void NrfLogger::Init() {
  auto result = NRF_LOG_INIT(nullptr);
  APP_ERROR_CHECK(result);

  NRF_LOG_DEFAULT_BACKENDS_INIT();

  if (pdPASS != xTaskCreate(NrfLogger::Process, "LOGGER", 512, nullptr, 0, &m_logger_thread))
    APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}

void NrfLogger::Process(void*) {
  NRF_LOG_INFO("Logger task started!");
  while (1) {
    NRF_LOG_FLUSH();
    vTaskSuspend(nullptr);
  }
}

void NrfLogger::Resume() {
  vTaskResume(m_logger_thread);
}