File tree Expand file tree Collapse file tree 2 files changed +17
-14
lines changed Expand file tree Collapse file tree 2 files changed +17
-14
lines changed Original file line number Diff line number Diff line change 16
16
--
17
17
local core = require (" apisix.core" )
18
18
local log_util = require (" apisix.utils.log-util" )
19
- local logger_socket = require " resty.logger.socket"
19
+ local logger_socket = require ( " resty.logger.socket" )
20
20
local plugin_name = " syslog"
21
21
local ngx = ngx
22
22
@@ -49,15 +49,12 @@ function _M.check_schema(conf)
49
49
end
50
50
51
51
function _M .flush_syslog (logger )
52
- if logger .initted () then
53
- local ok , err = logger :flush ()
52
+ local ok , err = logger :flush (logger )
54
53
if not ok then
55
54
core .log .error (" failed to flush message:" , err )
56
55
end
57
- end
58
56
end
59
57
60
-
61
58
function _M .log (conf )
62
59
local entry = log_util .get_full_log (ngx )
63
60
@@ -79,11 +76,11 @@ function _M.log(conf)
79
76
tls = conf .tls ,
80
77
})
81
78
82
- if not ok then
79
+ if not logger then
83
80
core .log .error (" failed when initiating the sys logger processor" , err )
84
81
end
85
82
86
- local ok , err = logger . log (core .json .encode (entry ))
83
+ local ok , err = logger : log (core .json .encode (entry ))
87
84
if not ok then
88
85
core .log .error (" failed to log message" , err )
89
86
end
Original file line number Diff line number Diff line change 110
110
},
111
111
" upstream" : {
112
112
" nodes" : {
113
- " 127.0.0.1:1984 " : 1
113
+ " 127.0.0.1:1980 " : 1
114
114
},
115
115
" type" : " roundrobin"
116
116
},
127
127
},
128
128
" upstream" : {
129
129
" nodes" : {
130
- " 127.0.0.1:1984 " : 1
130
+ " 127.0.0.1:1980 " : 1
131
131
},
132
132
" type" : " roundrobin"
133
133
},
@@ -171,13 +171,19 @@ hello world
171
171
local plugin = require (" apisix.plugins.syslog" )
172
172
local logger_socket = require " resty.logger.socket"
173
173
local logger, err = logger_socket: new({
174
- host = " 127.0.0.1" ,
175
- port = 5044 ,
176
- flush_limit = 1 ,
174
+ host = " 127.0.0.1" ,
175
+ port = 5044 ,
176
+ flush_limit = 100 ,
177
177
})
178
178
179
- if not logger then
180
- ngx. log (ngx. ERR, " failed to create logger: " , err)
179
+ local bytes , err = logger: log(" abc" )
180
+ if err then
181
+ ngx. log (ngx. ERR, err)
182
+ end
183
+
184
+ local bytes , err = logger: log(" efg" )
185
+ if err then
186
+ ngx. log (ngx. ERR, err)
181
187
end
182
188
183
189
local ok , err = plugin. flush_syslog(logger)
You can’t perform that action at this time.
0 commit comments