-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.c
47 lines (42 loc) · 1004 Bytes
/
logger.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "logger.h"
static logLevel_t LOG_LEVEL = DEBUG;
/**
* @brief Debug Level Name
* @param [in] selectLogLevel
* @return [const char*] Debug Level String
*/
static const char *debugLevelGetString(logLevel_t selectLogLevel)
{
if (selectLogLevel <= ASSERT)
return "ASSRT";
else if (selectLogLevel <= ERROR)
return "ERROR";
else if (selectLogLevel <= WARNING)
return "WARN";
else if (selectLogLevel <= INFO)
return "INFO";
return "DEBUG";
}
void setLogLevel(logLevel_t logLevel)
{
LOG_LEVEL = logLevel;
}
int debug_printf(logLevel_t logLevel,const char* function, const char* file, const int line, const char *format,...)
{
#ifdef DEBUGGER
if ( logLevel <= LOG_LEVEL )
{
fprintf(stdout,"[%s]%s %s(%d) ",debugLevelGetString(logLevel),file,function,line);
va_list va;
va_start(va,format);
va_end(va);
vfprintf(stdout,format,va);
}
#else
(void)function;
(void)file;
(void)line;
(void)format;
#endif
return 0;
}