-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.lua
49 lines (43 loc) · 1.11 KB
/
config.lua
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
local cjson = require "cjson"
local _dynamicConfig = {
-- 全局关键字
GLOBAL_KEYWORDS = {}
}
local _M = {
-- 日志级别文案
LVL_EMARGENCY = 'emargency',
LVL_ALERT = 'alert',
LVL_CRITICAL = 'critical',
LVL_ERROR = 'error',
LVL_WARNING = 'warning',
LVL_NOTICE = 'notice',
LVL_INFO = 'info',
LVL_DEBUG = 'debug',
-- 全局默认日志级别为info
GLOBAL_LOG_LEVEL = 'info',
-- 全局默认日志路径
GLOBAL_LOG_FULL_PATH = '/home/www/server/lua_api/logs'
}
local shared = ngx.shared.logConfig
function _M.get(self, name)
return shared:get(name)
end
function _M.init(self)
for k, v in pairs(_dynamicConfig) do
shared:set(k, cjson.encode(v));
end
end
-- 设定全局关键字
-- @param keywords table
-- keywords = {
-- keywordName1 = {'keywordContent1', 'keywordContent2'},
-- keywordName2 = 'keywordContent21'
-- }
-- @return string globalKeywords 全局关键字
function _M.setGlobalKeywords(self, keywords)
if keywords == nil then
return nil
end
shared:set('GLOBAL_KEYWORDS', cjson.encode(keywords))
end
return _M