-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.cpp
35 lines (32 loc) · 1.31 KB
/
common.cpp
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
#include "common.h"
void write(MsgLevel eMsgLevel, const char* pFile, const int nLine, const char* psFmt, ...) {
va_list l_args;
char l_sMsg[LOG_DEFAULT_SIZE + 1] = {0};
va_start(l_args, psFmt);
vsnprintf(l_sMsg, LOG_DEFAULT_SIZE, psFmt, l_args);
va_end(l_args);
switch (eMsgLevel) {
case SUCC:
fprintf(stderr, "File=%s.Line=%d. level=SUCC. err message=%s\r\n", pFile, nLine, l_sMsg);
break;
case INFO:
fprintf(stderr, "File=%s.Line=%d. level=INFO. err message=%s\r\n", pFile, nLine, l_sMsg);
break;
case WARNING:
fprintf(stderr, "File=%s.Line=%d. level=WARNING. err message=%s\r\n", pFile, nLine, l_sMsg);
break;
case ERROR:
fprintf(stderr, "File=%s.Line=%d. level=ERROR. err message=%s\r\n", pFile, nLine, l_sMsg);
break;
case SERIOUS:
fprintf(stderr, "File=%s.Line=%d. level=SERIOUS. err message=%s\r\n", pFile, nLine, l_sMsg);
break;
case UNKNOWN:
fprintf(stderr, "File=%s.Line=%d. level=UNKNOWN. err message=%s\r\n", pFile, nLine, l_sMsg);
break;
default:
break;
fprintf(stderr, "File=%s.Line=%d. Invalid argument level=%d\r\n", pFile, nLine, eMsgLevel);
}
fflush(stderr);
}