-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.c
More file actions
37 lines (30 loc) · 679 Bytes
/
debug.c
File metadata and controls
37 lines (30 loc) · 679 Bytes
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
#include "debug.h"
#include <stdarg.h>
#include <stdio.h>
void lwpLog(int type, const char *str, ...)
{
char *typePrefixCodes;
char *typePrefix;
switch (type)
{
case LOG_ERROR:
typePrefixCodes = "\x1b[31m\x1b[1m";
typePrefix = "ERROR";
break;
case LOG_INFO:
typePrefixCodes = "\x1b[34m\x1b[1m";
typePrefix = "INFO";
break;
case LOG_WARNING:
typePrefixCodes = "\x1b[33m\x1b[1m";
typePrefix = "WARNING";
break;
}
printf("%s%s: \x1b[0m", typePrefixCodes, typePrefix);
va_list args;
va_start(args, str);
vprintf(str, args);
va_end(args);
putchar('\n');
fflush(stdout);
}