-
Notifications
You must be signed in to change notification settings - Fork 0
/
wlog_lua_enums.c
105 lines (89 loc) · 2.06 KB
/
wlog_lua_enums.c
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* =====================================================================================
*
* Filename: wlog_lua_enums.c
*
* Description:
*
* Version: 1.0
* Created: 26/06/16 18:06:46
* Revision: none
* Compiler: gcc
*
* Author: Di Carlo Walter (DCW),
* Organization:
*
* =====================================================================================
*/
#include "wlog_lua_enums.h"
#include "wlog.h"
static void lua_push_enum_WLOG_LEVELS(lua_State *L)
{
lua_getglobal(L,"wlog");
lua_pushstring(L,"core");
lua_rawget(L,-2);
lua_pushstring(L,"enums");
lua_rawget(L,-2);
lua_pushstring(L, "WLOG_LEVELS");
lua_newtable(L); /* We will pass a table */
PUSH_ENUM(LOG_ERR);
PUSH_ENUM(LOG_WARN);
PUSH_ENUM(LOG_INFO);
PUSH_ENUM(LOG_TRACE);
PUSH_ENUM(LOG_DEBUG);
lua_rawset(L,-3);
lua_pop(L, 2);
}
static void lua_push_enum_WLOG_FUNCS(lua_State *L)
{
lua_getglobal(L,"wlog");
lua_pushstring(L,"core");
lua_rawget(L,-2);
lua_pushstring(L,"enums");
lua_rawget(L,-2);
lua_pushstring(L, "WLOG_FUNCTS");
lua_newtable(L); /* We will pass a table */
PUSH_ENUM(LOG_GEN);
PUSH_ENUM(LOG_ALM);
PUSH_ENUM(LOG_SYS);
PUSH_ENUM(LOG_SQL);
PUSH_ENUM(LOG_GUI);
PUSH_ENUM(LOG_SRV);
PUSH_ENUM(LOG_WEB);
lua_rawset(L,-3);
lua_pop(L, 2);
}
const char * wlog_getLevelName(const unsigned int level)
{
switch(level) {
case LOG_ERR:
return "LOG_ERR";
break;
case LOG_WARN:
return "LOG_WARN";
break;
case LOG_INFO:
return "LOG_INFO";
break;
case LOG_TRACE:
return "LOG_TRACE";
break;
case LOG_DEBUG:
return "LOG_DEBUG";
break;
default:
return ""; /* error */
}
}
void wlog_push_enums(lua_State *L)
{
lua_getglobal(L,"wlog");
lua_pushstring(L,"core");
lua_rawget(L,-2);
lua_pushstring(L,"enums");
lua_newtable(L);
lua_rawset(L,-3);
lua_pop(L,1);
lua_push_enum_WLOG_LEVELS(L);
lua_push_enum_WLOG_FUNCS(L);
}