Enable CLI logging (#670)

* enable uart logging
This commit is contained in:
Buke Po
2016-09-24 11:43:49 +08:00
committed by Jonathan Hui
parent 8d6923fe8b
commit 3452933fc5
5 changed files with 180 additions and 1 deletions
+94
View File
@@ -43,6 +43,7 @@
#include <common/encoding.hpp>
#include <common/new.hpp>
#include <common/tasklet.hpp>
#include <platform/logging.h>
#include <platform/uart.h>
namespace Thread {
@@ -214,5 +215,98 @@ void Uart::SendDoneTask(void)
Send();
}
#if OPENTHREAD_ENABLE_CLI_LOGGING
#ifdef __cplusplus
extern "C" {
#endif
void otCliLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
if (NULL == Uart::sUartServer)
{
return;
}
switch (aLogLevel)
{
case kLogLevelNone:
Uart::sUartServer->OutputFormat("NONE ");
break;
case kLogLevelCrit:
Uart::sUartServer->OutputFormat("CRIT ");
break;
case kLogLevelWarn:
Uart::sUartServer->OutputFormat("WARN ");
break;
case kLogLevelInfo:
Uart::sUartServer->OutputFormat("INFO ");
break;
case kLogLevelDebg:
Uart::sUartServer->OutputFormat("DEBG ");
break;
default:
return;
}
switch (aLogRegion)
{
case kLogRegionApi:
Uart::sUartServer->OutputFormat("API ");
break;
case kLogRegionMle:
Uart::sUartServer->OutputFormat("MLE ");
break;
case kLogRegionArp:
Uart::sUartServer->OutputFormat("ARP ");
break;
case kLogRegionNetData:
Uart::sUartServer->OutputFormat("NETD ");
break;
case kLogRegionIp6:
Uart::sUartServer->OutputFormat("IPV6 ");
break;
case kLogRegionIcmp:
Uart::sUartServer->OutputFormat("ICMP ");
break;
case kLogRegionMac:
Uart::sUartServer->OutputFormat("MAC ");
break;
case kLogRegionMem:
Uart::sUartServer->OutputFormat("MEM ");
break;
case kLogRegionNcp:
Uart::sUartServer->OutputFormat("NCP ");
break;
case kLogRegionMeshCoP:
Uart::sUartServer->OutputFormat("MCOP ");
break;
default:
return;
}
va_list args;
va_start(args, aFormat);
Uart::sUartServer->OutputFormat(aFormat, args);
va_end(args);
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif // OPENTHREAD_ENABLE_CLI_LOGGING
} // namespace Cli
} // namespace Thread