-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.h
More file actions
37 lines (29 loc) · 916 Bytes
/
logger.h
File metadata and controls
37 lines (29 loc) · 916 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
37
#ifndef _CLOTHSIM_LOGGING_H
#define _CLOTHSIM_LOGGING_H
/*
Little logging utility made for for fun
Made by Nathan Lapp. March 2023
*/
#include <assert.h>
#include <stdarg.h>
#include <stdint.h>
//Enum of different log levels, indicates indice into LOG_PREFIXES
enum LogLevel
{
INFO,
ERROR,
WARNING
};
void debug_log(int line, const char* file,enum LogLevel level,const char* fmt,...);
//Helper macro to print out INFO logs
#define LOG_INFO(fmt,...) debug_log(__LINE__,__FILE__,INFO,fmt,__VA_ARGS__)
//Helper macro to print out ERROR logs
#define LOG_ERROR(fmt,...) debug_log(__LINE__,__FILE__,ERROR,fmt,__VA_ARGS__)
//Helper macro to print out WARNING logs
#define LOG_WARNING(fmt,...) debug_log(__LINE__,__FILE__,WARNING,fmt,__VA_ARGS__)
//Helper macro for assertions
#define ASSERT(expr,fmt,...) if(!expr){\
d_debug_log(__LINE__,__FILE__,ERROR,fmt,__VA_ARGS__);\
assert(expr);\
}
#endif