summaryrefslogtreecommitdiff
path: root/src/Logging/NrfLogger.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2019-11-17 20:47:04 +0100
committerJF <jf@codingfield.com>2019-11-17 20:47:04 +0100
commit2ea27e0cdac91cd4743d9f12496bb3f911d9efa9 (patch)
treeae6488be1be14c2b83aff6e69a6e622088fb093a /src/Logging/NrfLogger.cpp
Initial commit
Diffstat (limited to 'src/Logging/NrfLogger.cpp')
-rw-r--r--src/Logging/NrfLogger.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Logging/NrfLogger.cpp b/src/Logging/NrfLogger.cpp
new file mode 100644
index 00000000..06639401
--- /dev/null
+++ b/src/Logging/NrfLogger.cpp
@@ -0,0 +1,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);
+}
+
+