Improve:LedControl and Log include cleaner.
This commit is contained in:
parent
833b69a823
commit
67d5e2014f
|
@ -27,7 +27,7 @@ llvm-twine-local,\
|
||||||
misc-confusable-identifiers,\
|
misc-confusable-identifiers,\
|
||||||
misc-definitions-in-headers,\
|
misc-definitions-in-headers,\
|
||||||
misc-header-include-cycle,\
|
misc-header-include-cycle,\
|
||||||
-misc-include-cleaner,\
|
misc-include-cleaner,\
|
||||||
misc-misleading-bidirectional,\
|
misc-misleading-bidirectional,\
|
||||||
misc-misleading-identifier,\
|
misc-misleading-identifier,\
|
||||||
misc-misplaced-const,\
|
misc-misplaced-const,\
|
||||||
|
@ -55,7 +55,7 @@ set(CLANG_FORMAT_FILE "LLVM ${CMAKE_SOURCE_DIR_IPCSDK}/tools/clang-format/.clang
|
||||||
if(${LINUX_TEST} MATCHES "true")
|
if(${LINUX_TEST} MATCHES "true")
|
||||||
set(CLANG_TIDY_SUPPORT "true")
|
set(CLANG_TIDY_SUPPORT "true")
|
||||||
set(CLANG_FORMAT_SUPPORT "true")
|
set(CLANG_FORMAT_SUPPORT "true")
|
||||||
set(COMPILE_IMPROVE_SUPPORT "false") # 开启后每次编译可能会很慢
|
set(COMPILE_IMPROVE_SUPPORT "true") # 开启后每次编译可能会很慢
|
||||||
set(LLVM_PATH "$ENV{HOME}/llvm-project")
|
set(LLVM_PATH "$ENV{HOME}/llvm-project")
|
||||||
endif()
|
endif()
|
||||||
# ------------ build clang-tools end ------------ #
|
# ------------ build clang-tools end ------------ #
|
||||||
|
|
|
@ -14,7 +14,10 @@
|
||||||
*/
|
*/
|
||||||
#include "LedControl.h"
|
#include "LedControl.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
StatusCode VSingleControl::GetLedState(LedState &state)
|
StatusCode VSingleControl::GetLedState(LedState &state)
|
||||||
{
|
{
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
|
|
@ -13,21 +13,21 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "ILog.h"
|
||||||
#include "ILogCpp.h"
|
#include "ILogCpp.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <stdlib.h>
|
||||||
#include <memory>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
static void LogFree(ILog *object)
|
static void LogFree(ILog *object)
|
||||||
{
|
{
|
||||||
printf("log instance free.\n");
|
printf("log instance free.\n");
|
||||||
if (object)
|
if (object) {
|
||||||
{
|
|
||||||
free(object);
|
free(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static int LogPrintf(ILog *object, const char *function, const int line, const enum LogType type, const char *format, ...)
|
static int LogPrintf(ILog *object, const char *function, const int line, const enum LogType type, const char *format,
|
||||||
|
...)
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO:
|
||||||
// LogTypeToString(type);
|
// LogTypeToString(type);
|
||||||
|
@ -40,8 +40,7 @@ static int LogPrintf(ILog *object, const char *function, const int line, const e
|
||||||
va_start(vargs, format);
|
va_start(vargs, format);
|
||||||
int len = vsnprintf(buff + headLen, SEND_TRACE_BUFF_SIZE - headLen, format, vargs);
|
int len = vsnprintf(buff + headLen, SEND_TRACE_BUFF_SIZE - headLen, format, vargs);
|
||||||
va_end(vargs);
|
va_end(vargs);
|
||||||
switch (type)
|
switch (type) {
|
||||||
{
|
|
||||||
case LOG_TYPE_INFORMATION:
|
case LOG_TYPE_INFORMATION:
|
||||||
ILogCpp::GetInstance()->InFo(buff);
|
ILogCpp::GetInstance()->InFo(buff);
|
||||||
break;
|
break;
|
||||||
|
@ -75,16 +74,13 @@ static void LogImplInit(Log *log)
|
||||||
}
|
}
|
||||||
void NewLog(Log **log)
|
void NewLog(Log **log)
|
||||||
{
|
{
|
||||||
if (!log)
|
if (!log) {
|
||||||
{
|
|
||||||
printf("STATUS_CODE_INVALID_PARAMENTER\n");
|
printf("STATUS_CODE_INVALID_PARAMENTER\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(*log))
|
if (!(*log)) {
|
||||||
{
|
|
||||||
*log = (Log *)malloc(sizeof(Log));
|
*log = (Log *)malloc(sizeof(Log));
|
||||||
if (*log)
|
if (*log) {
|
||||||
{
|
|
||||||
printf("NewLog succeed.\n");
|
printf("NewLog succeed.\n");
|
||||||
NewILog((ILog **)log);
|
NewILog((ILog **)log);
|
||||||
LogImplInit(*log);
|
LogImplInit(*log);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user