From ca55a983700437e5ca2f6e1517bc5b6670d14154 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 14 Nov 2017 21:54:39 -0800 Subject: mpm: ad937x: Make log functions go through central logger Reviewed-By: Mark Meserve --- mpm/lib/mykonos/adi_ctrl.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/mpm/lib/mykonos/adi_ctrl.cpp b/mpm/lib/mykonos/adi_ctrl.cpp index e026466de..0c2ef9368 100644 --- a/mpm/lib/mykonos/adi_ctrl.cpp +++ b/mpm/lib/mykonos/adi_ctrl.cpp @@ -18,7 +18,9 @@ #include "adi/common.h" #include +#include #include +#include #include #include @@ -271,11 +273,30 @@ commonErr_t CMB_closeLog(void) return COMMONERR_FAILED; } -commonErr_t CMB_writeToLog(ADI_LOGLEVEL level, uint8_t deviceIndex, uint32_t errorCode, const char *comment) -{ - // TODO: send to logging API - // TODO: filter log messages based on level - std::cout << "[CMB_writeToLog] level==" << level << " errorCode==" << errorCode << " " << comment; +commonErr_t CMB_writeToLog( + ADI_LOGLEVEL level, + uint8_t deviceIndex, + uint32_t errorCode, + const char *comment +) { + mpm::types::log_level_t mpm_log_level; + if (level & ADIHAL_LOG_ERROR) { + mpm_log_level = mpm::types::log_level_t::ERROR; + } + else if (level & ADIHAL_LOG_WARNING) { + mpm_log_level = mpm::types::log_level_t::WARNING; + } + else { + mpm_log_level = mpm::types::log_level_t::TRACE; + } + + mpm::types::log_buf::make_singleton()->post( + mpm_log_level, + "AD937X", + str(boost::format("[Device ID %d] [Error code: %d] %s") + % int(deviceIndex) % errorCode % comment) + ); + return COMMONERR_OK; } commonErr_t CMB_flushLog(void) -- cgit v1.2.3