Skip to content

Commit 64ca3d3

Browse files
committed
Fix typos and correct grammar errors
1 parent fd7962d commit 64ca3d3

4 files changed

Lines changed: 45 additions & 43 deletions

File tree

lib/resty/logger/socket.lua

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Copyright (C) 2013-2014 Jiale Zhi (calio), Cloudflare Inc.
1+
-- Copyright (C) 2013-2014 Jiale Zhi (calio), CloudFlare Inc.
22
--require "luacov"
33

44
local concat = table.concat
@@ -32,10 +32,10 @@ if not ngx.config or not ngx.config.ngx_lua_version
3232

3333
is_exiting = function() return false end
3434

35-
ngx_log(CRIT, "lua-resty-logger-socket working with ngx_lua module < 0.9.3"
36-
.. " has a serious issue that some log messages may be lost when"
37-
.. " nginx reloads. We strongly recommend you update your ngx_lua"
38-
.. " module to at least 0.9.3")
35+
ngx_log(CRIT, "We strongly recommend you to update your ngx_lua module to "
36+
.. "0.9.3 or above. lua-resty-logger-socket will lose some log "
37+
.. "messages when Nginx reloads if it works with ngx_lua module "
38+
.. "below 0.9.3")
3939
else
4040
is_exiting = ngx.worker.exiting
4141
end
@@ -59,7 +59,7 @@ local buffer_size = 0
5959
local send_buffer = ""
6060
-- 1st level buffer, it stores incoming logs
6161
local log_buffer_data = new_tab(20000, 0)
62-
-- number of log lines in current buffer, starts from 0
62+
-- number of log lines in current 1st level buffer, starts from 0
6363
local log_buffer_index = 0
6464

6565
local last_error
@@ -95,7 +95,7 @@ local function _do_connect()
9595
sock:settimeout(timeout)
9696
end
9797

98-
-- host/port and path config have already been checked in init()
98+
-- "host"/"port" and "path" have already been checked in init()
9999
if host and port then
100100
ok, err = sock:connect(host, port)
101101
elseif path then
@@ -114,9 +114,9 @@ local function _connect()
114114

115115
if connecting then
116116
if debug then
117-
ngx_log(DEBUG, "previous connect not finished")
117+
ngx_log(DEBUG, "previous connection not finished")
118118
end
119-
return nil, "previous connect not finished"
119+
return nil, "previous connection not finished"
120120
end
121121

122122
connected = false
@@ -133,10 +133,10 @@ local function _connect()
133133
end
134134

135135
if debug then
136-
ngx_log(DEBUG, "retry to connect to the log server: ", err)
136+
ngx_log(DEBUG, "reconnect to the log server: ", err)
137137
end
138138

139-
-- ngx.sleep use seconds to count time
139+
-- ngx.sleep time is in seconds
140140
if not exiting then
141141
ngx_sleep(retry_interval / 1000)
142142
end
@@ -163,8 +163,8 @@ local function _prepare_stream_buffer()
163163
log_buffer_data = new_tab(20000, 0)
164164
counter = 0
165165
if debug then
166-
ngx_log(DEBUG, "log buffer max reuse(" .. max_buffer_reuse
167-
.. ") reached, create new log_buffer_data")
166+
ngx_log(DEBUG, "log buffer reuse limit (" .. max_buffer_reuse
167+
.. ") reached, create a new \"log_buffer_data\"")
168168
end
169169
end
170170
end
@@ -178,7 +178,7 @@ local function _do_flush()
178178

179179
local bytes, err = sock:send(packet)
180180
if not bytes then
181-
-- sock:send always close current connection on error
181+
-- "sock:send" always closes current connection on error
182182
return nil, err
183183
end
184184

@@ -206,7 +206,7 @@ end
206206
local function _flush_lock()
207207
if not flushing then
208208
if debug then
209-
ngx_log(DEBUG, "flush lock accquired")
209+
ngx_log(DEBUG, "flush lock acquired")
210210
end
211211
flushing = true
212212
return true
@@ -235,7 +235,7 @@ local function _flush()
235235

236236
if not _need_flush() then
237237
if debug then
238-
ngx_log(DEBUG, "do not need to flush:", log_buffer_index)
238+
ngx_log(DEBUG, "no need to flush:", log_buffer_index)
239239
end
240240
_flush_unlock()
241241
return true
@@ -260,10 +260,10 @@ local function _flush()
260260
end
261261

262262
if debug then
263-
ngx_log(DEBUG, "retry to send log message to the log server: ", err)
263+
ngx_log(DEBUG, "resend log messages to the log server: ", err)
264264
end
265265

266-
-- ngx.sleep use seconds to count time
266+
-- ngx.sleep time is in seconds
267267
if not exiting then
268268
ngx_sleep(retry_interval / 1000)
269269
end
@@ -274,7 +274,7 @@ local function _flush()
274274
_flush_unlock()
275275

276276
if not bytes then
277-
local err_msg = "try to send log message to the log server "
277+
local err_msg = "try to send log messages to the log server "
278278
.. "failed after " .. max_retry_times .. " retries: "
279279
.. err
280280
_write_error(err_msg)
@@ -326,7 +326,7 @@ function _M.init(user_config)
326326
elseif k == "max_retry_times" then
327327
max_retry_times = v
328328
elseif k == "retry_interval" then
329-
-- ngx.sleep uses seconds to count sleep time
329+
-- ngx.sleep time is in seconds
330330
retry_interval = v
331331
elseif k == "pool_size" then
332332
pool_size = v
@@ -336,12 +336,13 @@ function _M.init(user_config)
336336
end
337337

338338
if not (host and port) and not path then
339-
return nil, "no logging server configured. Need host/port or path."
339+
return nil, "no logging server configured. \"host\"/\"port\" or "
340+
.. "\"path\" is required."
340341
end
341342

342343

343344
if (flush_limit >= drop_limit) then
344-
return nil, "flush_limit should < drop_limit"
345+
return nil, "\"flush_limit\" should be < \"drop_limit\""
345346
end
346347

347348
flushing = false
@@ -375,14 +376,14 @@ function _M.log(msg)
375376

376377
local msg_len = #msg
377378

378-
-- return result of _flush_buffer is not checked, because it writes
379+
-- response of "_flush_buffer" is not checked, because it writes
379380
-- error buffer
380381
if (is_exiting()) then
381382
exiting = true
382383
_write_buffer(msg)
383384
_flush_buffer()
384385
if (debug) then
385-
ngx_log(DEBUG, "worker exiting")
386+
ngx_log(DEBUG, "Nginx worker is exiting")
386387
end
387388
bytes = 0
388389
elseif (msg_len + buffer_size < flush_limit) then
@@ -395,10 +396,11 @@ function _M.log(msg)
395396
else
396397
_flush_buffer()
397398
if (debug) then
398-
ngx_log(DEBUG, "logger buffer is full, this log would be dropped")
399+
ngx_log(DEBUG, "logger buffer is full, this log message will be "
400+
.. "dropped")
399401
end
400402
bytes = 0
401-
--- this message does not fit in buffer, drop it
403+
--- this log message doesn't fit in buffer, drop it
402404
end
403405

404406
if last_error then

t/bug.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ GET /t?a=1&b=2
8989
--- tcp_reply:
9090
--- tcp_no_close
9191
--- grep_error_log chop
92-
retry to send log message to the log server: timeout
92+
resend log messages to the log server: timeout
9393
--- response_body
9494
foo
9595
foo
9696
foo
9797
--- grep_error_log_out
98-
retry to send log message to the log server: timeout
99-
retry to send log message to the log server: timeout
100-
retry to send log message to the log server: timeout
98+
resend log messages to the log server: timeout
99+
resend log messages to the log server: timeout
100+
resend log messages to the log server: timeout
101101

102102

103103

104-
=== TEST 2: insert new log message to buffer in the middle of last send (it's difficult to control the time sequence here, so this is skipped now)
104+
=== TEST 2: insert new log messages to buffer in the middle of last send (it's difficult to control the time sequence here, so this is skipped now)
105105
--- http_config eval: $::HttpConfig
106106
--- config
107107
log_subrequest on;

t/sanity.t

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ foo
147147

148148

149149

150-
=== TEST 4: buffer log message, no flush
150+
=== TEST 4: buffer log messages, no flush
151151
--- http_config eval: $::HttpConfig
152152
--- config
153153
location /t {
@@ -208,7 +208,7 @@ foo
208208

209209

210210

211-
=== TEST 6: log subrequest
211+
=== TEST 6: log subrequests
212212
--- http_config eval: $::HttpConfig
213213
--- config
214214
log_subrequest on;
@@ -262,7 +262,7 @@ foo
262262

263263

264264

265-
=== TEST 7: log subrequest, small flush_limit, flush twice
265+
=== TEST 7: log subrequests, small flush_limit, flush twice
266266
--- http_config eval: $::HttpConfig
267267
--- config
268268
log_subrequest on;
@@ -314,7 +314,7 @@ foo
314314

315315

316316

317-
=== TEST 8: do not log subrequest
317+
=== TEST 8: do not log subrequests
318318
--- http_config eval: $::HttpConfig
319319
--- config
320320
location /t {
@@ -426,7 +426,7 @@ foo
426426
--- request
427427
GET /t?a=1&b=2
428428
--- error_log
429-
no logging server configured. Need host/port or path.
429+
no logging server configured. "host"/"port" or "path" is required.
430430
--- response_body
431431
foo
432432

@@ -462,7 +462,7 @@ foo
462462
--- request
463463
GET /t?a=1&b=2
464464
--- error_log
465-
flush_limit should < drop_limit
465+
"flush_limit" should be < "drop_limit"
466466
--- response_body
467467
foo
468468

@@ -509,7 +509,7 @@ GET /t?a=1&b=2
509509
--- tcp_query_len: 6
510510
--- tcp_reply:
511511
--- error_log
512-
logger buffer is full, this log would be dropped
512+
logger buffer is full, this log message will be dropped
513513
--- response_body
514514
foo
515515

@@ -642,7 +642,7 @@ GET /t?a=1&b=2
642642
--- tcp_listen: 29999
643643
--- tcp_reply:
644644
--- error_log
645-
log buffer max reuse(1) reached, create new log_buffer_data
645+
log buffer reuse limit (1) reached, create a new "log_buffer_data"
646646
--- tcp_query: 111222333444555
647647
--- tcp_query_len: 15
648648
--- response_body

t/timeout.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ GET /t?a=1&b=2
8989
--- wait: 0.1
9090
--- error_log
9191
tcp socket connect timed out
92-
try to connect to the log server
92+
reconnect to the log server
9393
--- response_body
9494
foo
9595

@@ -125,7 +125,7 @@ GET /t?a=1&b=2
125125
--- tcp_reply:
126126
--- error_log
127127
lua tcp socket write timed out
128-
retry to send log message to the log server: timeout
128+
resend log messages to the log server: timeout
129129
--- response_body
130130
foo
131131

@@ -225,8 +225,8 @@ GET /main
225225
--- wait: 0.2
226226
--- error_log
227227
lua tcp socket connect timed out
228-
retry to connect to the log server: timeout
229-
log error:try to send log message to the log server failed after 1 retries: try to connect to the log server failed after 1 retries: timeout
228+
reconnect to the log server: timeout
229+
log error:try to send log messages to the log server failed after 1 retries: try to connect to the log server failed after 1 retries: timeout
230230
--- response_body
231231
foo
232232
bar

0 commit comments

Comments
 (0)