diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-11-14 21:54:39 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:06 -0800 |
commit | ca55a983700437e5ca2f6e1517bc5b6670d14154 (patch) | |
tree | 8cb8d8be1169126412671ad3076bff0926a92edd /mpm/lib/mykonos/adi_ctrl.cpp | |
parent | 5c63a83d22d99d8def9cb5c943853f579c533ada (diff) | |
download | uhd-ca55a983700437e5ca2f6e1517bc5b6670d14154.tar.gz uhd-ca55a983700437e5ca2f6e1517bc5b6670d14154.tar.bz2 uhd-ca55a983700437e5ca2f6e1517bc5b6670d14154.zip |
mpm: ad937x: Make log functions go through central logger
Reviewed-By: Mark Meserve <mark.meserve@ni.com>
Diffstat (limited to 'mpm/lib/mykonos/adi_ctrl.cpp')
-rw-r--r-- | mpm/lib/mykonos/adi_ctrl.cpp | 31 |
1 files 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 <mpm/ad937x/adi_ctrl.hpp> +#include <mpm/types/log_buf.hpp> #include <uhd/exception.hpp> +#include <boost/format.hpp> #include <iostream> #include <chrono> @@ -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) |