-
Notifications
You must be signed in to change notification settings - Fork 7
/
simplelogger_defs.h
56 lines (49 loc) · 1.28 KB
/
simplelogger_defs.h
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
48
49
50
51
52
53
54
55
56
/*
* Simple logging framework.
*
* License: Unlicense(http://unlicense.org)
*
* Find the latest version at https://github.com/rm5248/simplelogger
*
* Definitions for library usage. This is the file that must be distributed
* if you are using the Simplelogger in a library.
*/
#ifndef SIMPLELOGGER_DEFS_H
#define SIMPLELOGGER_DEFS_H
/**
* Where the log message was generated from.
*/
struct SL_LogLocation{
int line_number;
const char* function;
const char* file;
};
/**
* Level of the log message
*/
enum SL_LogLevel{
SL_TRACE,
SL_DEBUG,
SL_INFO,
SL_WARN,
SL_ERROR,
SL_FATAL
};
/**
* Pointer to a function that does the actual log operation.
*/
typedef void (*simplelogger_log_function)(const char* logger_name,
const struct SL_LogLocation* location,
const enum SL_LogLevel level,
const char* log_string );
#define SL_LOGLEVEL_TO_STRING( stringPtr, level ) do{\
switch( level ){ \
case SL_TRACE: stringPtr = "TRACE"; break;\
case SL_DEBUG: stringPtr = "DEBUG"; break;\
case SL_INFO: stringPtr = "INFO"; break;\
case SL_WARN: stringPtr = "WARN"; break;\
case SL_ERROR: stringPtr = "ERROR"; break;\
case SL_FATAL: stringPtr = "FATAL"; break;\
default: stringPtr = "UNKN"; break;\
}}while(0)
#endif /* SIMPLELOGGER_DEFS_H */