-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging.h
57 lines (48 loc) · 1.25 KB
/
logging.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
57
#ifndef __SN_LOGGING_H__
#define __SN_LOGGING_H__
/* If debugging is turned on, set a default debug level.
*/
#ifdef SN_DEBUG
#ifndef SN_DEBUG_LEVEL
#define SN_DEBUG_LEVEL 2
#endif //SN_DEBUG_LEVEL
#endif //SN_DEBUG
#ifdef SN_DEBUG
#ifndef __SDCC_mcs51
#include <inttypes.h>
#else //__SDCC_mcs51
#ifndef __FUNCTION__
#define __FUNCTION__ __func__
#endif //__FUNCTION__
#ifndef PRIx32
#define PRIx32 "lx"
#endif //PRIx32
#endif //__SDCC_mcs51
#include <stdio.h>
#include "sys/clock.h"
#include "cc253x.h"
#define SN_Printf(level, fmt, x...) printf("[T=% 6u](SP=0x%02x) SN_" level " %s: " fmt, clock_time(), SP, __FUNCTION__, ##x)
#else /* SN_DEBUG */
#define SN_Printf(x...)
#endif /* SN_DEBUG */
#if (SN_DEBUG_LEVEL > 0)
#define SN_ErrPrintf(fmt, x...) SN_Printf("ERROR", fmt, ##x)
#else //0
#define SN_ErrPrintf(x...)
#endif //0
#if (SN_DEBUG_LEVEL > 1)
#define SN_WarnPrintf(fmt, x...) SN_Printf("WARN", fmt, ##x)
#else //1
#define SN_WarnPrintf(x...)
#endif //1
#if (SN_DEBUG_LEVEL > 2)
#define SN_InfoPrintf(fmt, x...) SN_Printf("INFO", fmt, ##x)
#else //2
#define SN_InfoPrintf(x...)
#endif //2
#if (SN_DEBUG_LEVEL > 3)
#define SN_DebugPrintf(fmt, x...) SN_Printf("DEBUG", fmt, ##x)
#else //3
#define SN_DebugPrintf(x...)
#endif //3
#endif /* __SN_LOGGING_H__ */