Skip to content

upgrade nginx #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 74 commits into from
Aug 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
bd7ab97
checked in file dist.ini for OPM packaging.
agentzh Sep 29, 2016
730f7f1
optimize: resty.core.shdict: removed one unused top-level Lua variable.
thibaultcha Oct 25, 2016
7ae24d3
ssl.session: minor fixes and tweaks.
agentzh Oct 29, 2016
b14b0da
tests: ssl_session_fetch/store_by_lua_* are now only allowed in http …
doujiang24 Oct 30, 2016
57128f5
now we require at least ngx_lua 0.10.7.
agentzh Oct 31, 2016
32a51dc
feature: implemented the split() method in the ngx.re module.
thibaultcha Oct 22, 2016
fccfa33
dist.ini: updated the minimum ngx_lua version required.
agentzh Dec 16, 2016
1ad0efd
travis-ci: added nginx 1.11.2 to the test matrix.
alubbe Dec 16, 2016
69703fe
doc: updated copyright notice.
agentzh Dec 18, 2016
03d8a32
updated copyright notices.
agentzh Dec 19, 2016
dd9f57f
feature: resty.core.regex: exported internal helper functions collect…
agentzh Jan 2, 2017
8c0bf1c
bugfix: ngx.re: split() might enter infinite loops when the regex is …
doujiang24 Jan 7, 2017
a76cb9c
resty.core: made the warning louder by turning it to an alert when Lu…
agentzh Jan 9, 2017
4c53de3
optimize: avoided string concat in the previous commit. thanks Thibau…
agentzh Jan 9, 2017
8d1480a
travis-ci: updated openssl to 1.0.2j.
alubbe Jan 9, 2017
ef197ad
fixed or work-around warnings from luacheck.
agentzh Jan 12, 2017
edef856
travis-ci: added luacheck testing.
halfcrazy Jan 12, 2017
bd85d84
travis-ci: added checks for any uses of tabs and lines longer than 80…
agentzh Jan 12, 2017
729e186
tests: refactored tests to use _by_lua_block directives exclusively.
p0pr0ck5 Feb 13, 2017
b46a48f
luacheck: added 'coroutine._yield' to read-only globals.
thibaultcha Mar 11, 2017
5630639
tests: make use of the $TEST_NGINX_SERVER_ROOT macro variable in the …
agentzh Mar 25, 2017
b3de525
travis-ci: run the test suite in parallel jobs.
agentzh Mar 25, 2017
2cf8c4c
travis-ci: uses the git repo of test-nginx.
agentzh Mar 25, 2017
890000e
tests: suppressed one conditional move/jump valgrind error which migh…
agentzh Mar 25, 2017
d96205d
doc: fixed a typo in balancer.md.
xiaoxuanzi Mar 27, 2017
4fff68d
tests: updated valgrind.suppress to suppress a known "Conditional jum…
agentzh Apr 3, 2017
741bbf0
change: now we require ngx_http_lua_module 0.10.8+.
agentzh Apr 8, 2017
ae74c9a
bumped version to 0.1.11.
agentzh Apr 8, 2017
ddd544d
opm: fixed the deps in dist.ini.
agentzh Apr 11, 2017
be97dea
travis-ci: use pcre 8.40 and enable pcre jit.
alubbe Apr 11, 2017
9903f1a
doc: a typo fixe in Synopsis.
Apr 12, 2017
a548fbb
optimize: simplified the "BOOL and true or false" expressions.
jsopenrb Apr 19, 2017
f23cce4
tests: removed extra file trailing newlines from the test files via t…
membphis Apr 20, 2017
42f3b41
doc: ngx.ssl: a typo fix.
membphis May 1, 2017
a79387c
feature: added opt() function to the ngx.re Lua module that accepts t…
alubbe Jun 3, 2016
392976c
travis-ci: enable -msse4.2 when building luajit2.
agentzh May 6, 2017
ae79bf7
feature: added new Lua module ngx.process which has functions type() …
membphis Apr 16, 2017
f9ae2d3
now we require at least ngx_lua 0.10.9.
agentzh May 7, 2017
de9e1ce
bumped version number to 0.1.12.
agentzh May 8, 2017
e14696c
doc: updated the TOC section in lib/ngx/re.md file with markdown-toc.pl.
spacewander May 8, 2017
92e6053
doc: ngx.process: more details on the privileged agent process.
agentzh May 10, 2017
b806b49
tests & docs: minor tweaks.
membphis May 11, 2017
4d3d773
doc: fixed the code example since directives `ssl_session_*_by_lua*` …
membphis May 12, 2017
1d7cfc0
feature: added new Lua module ngx.errlog which provides Lua API to ca…
membphis Apr 13, 2017
577dfee
doc: ngx.errlog: added more docs.
agentzh May 13, 2017
5e21d0e
change: updatd to reflect the recent renaming of the lua_intercept_er…
agentzh May 13, 2017
8dfe456
change: ngx.errlog: renamed set_errlog_filter() to set_filter_level()…
agentzh May 14, 2017
c600057
doc: ngx.re: opt(): fixed the obsolete code example.
agentzh May 14, 2017
f81a556
feature: added the new signal_graceful_exit() function to the ngx.pro…
agentzh May 14, 2017
d42aa9a
doc: ngx.process: made the docs for signal_graceful_exit() clearer.
agentzh May 15, 2017
4a7d1dc
doc: ngx.ssl.session: fixed the missing arguments in the code example.
noname007 May 18, 2017
16a4831
doc: code example: private keys are usually stored in PEM, so we use …
noname007 May 18, 2017
3031e5f
bugfix: ngx.errlog: get_logs(): we did not set `nil` at the current t…
membphis May 18, 2017
7cd1a03
feature: ngx.errlog: added the get_sys_filter_level() API function to…
spacewander May 22, 2017
1928892
doc: ngx.balancer: fixed some typos in balancer.md.
detailyang Jun 8, 2017
238c150
bugfix: ngx.re: split() might enter infinite loops when the regex yie…
thibaultcha May 16, 2017
285c155
doc: fixed some typos detected by misspell.
spacewander Jun 14, 2017
3d6c823
feature: ngx.errlog: get_logs(): now we return the UNIX timestamps wi…
membphis Jun 26, 2017
8d262d9
doc: ngx.errlog: get_logs(): fixed a typo.
Jul 3, 2017
6cd0c0e
tests: added test cases for error log ringbuf bugs.
pracj3am Jun 27, 2017
6425687
tests: skipped several short-connection tests in the check leak testi…
agentzh Jul 5, 2017
7216bf9
tests: fixed failures when TEST_NGINX_USE_STAP env is set.
agentzh Jul 5, 2017
ed8c20e
tests: fixed test failures on i386.
agentzh Jul 6, 2017
9c3a1b8
tests: proces-type-hup.t: disabled long string output in case of test…
agentzh Jul 6, 2017
4c7f596
tests: simplified a test case.
agentzh Jul 6, 2017
6a11c6e
travis-ci: avoided using the contributor's branch of ngx_lua. thanks …
agentzh Jul 6, 2017
bb8b7f6
tests: consolidated a test case in the mockeagain writing test mode.
agentzh Jul 9, 2017
931d3f4
a followup fix for the previous commit.
agentzh Jul 9, 2017
5e959d5
tests: skipped a test case in check leak mode.
agentzh Jul 9, 2017
add6d39
test: mark fractional part as optional to avoid unexpected failure.
spacewander Jul 9, 2017
10c4d7d
misc: added templates for issue and pull request.
spacewander Jul 26, 2017
06c81cd
doc: ngx.ssl: added performace notes for set_priv_key() and set_cert().
Aug 1, 2017
3d1f097
tests: fixed a skip test count.
agentzh Aug 6, 2017
47c22c0
dist.ini: now we require ngx_lua >= 0.10.9.
agentzh Aug 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This place is for bug reports and development discussions only. For general questions and
discussions, please join the openresty-en mailing list instead: https://groups.google.com/group/openresty-en.
If you want to use Chinese, please join the openresty (Chinese) mailing list instead: https://groups.google.com/group/openresty.
Do not use Chinese in this place.

Before you open a new issue, please search the internet and make sure it is not duplicate.

Ensure you have provided the following details while reporting a problem:

- [ ] The exact version of the related software, including but not limited to the OpenResty version
(if any), the NGINX core version, the `ngx_lua` module version(via `openresty -V` or `nginx -V`),
and the `lua-resty-core` version(via `resty -e 'print(require("resty.core").version)'`),
and your operating system version(via `uname -a`).
- [ ] **A minimal and standalone test case** that others can easily run on their side and
reproduce the issue you are seeing.
- [ ] Do not simply say "something is broken" or "something does not work". Always provide
as much details as possible. Always describe **the symptoms and your expected results**.

You can (temporarily) enable the nginx debugging logs to see the internal workings
of NGINX in your nginx''s `error.log` file. See http://nginx.org/en/docs/debugging_log.html
The same instructions apply equally well to OpenResty.

If you are seeing crashes, please provide the full backtrace for the crash. See
https://www.nginx.com/resources/wiki/start/topics/tutorials/debugging/#core-dump
for more details.

Thanks for your cooperation.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
I hereby granted the copyright of the changes in this pull request
to the authors of this lua-resty-core project.
5 changes: 5 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
std = 'ngx_lua'
unused_args = false
read_globals = {
"coroutine._yield"
}
43 changes: 30 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,52 @@ compiler:
- gcc
- clang

addons:
apt:
packages:
- cpanminus
- axel
- luarocks

cache:
directories:
- download-cache

env:
global:
- JOBS=3
- JOBS=2
- NGX_BUILD_JOBS=$JOBS
- LUAJIT_PREFIX=/opt/luajit21
- LUAJIT_LIB=$LUAJIT_PREFIX/lib
- LUAJIT_INC=$LUAJIT_PREFIX/include/luajit-2.1
- LUA_INCLUDE_DIR=$LUAJIT_INC
- LUA_CMODULE_DIR=/lib
- PCRE_VER=8.40
- OPENSSL_PREFIX=/opt/ssl
- OPENSSL_LIB=$OPENSSL_PREFIX/lib
- OPENSSL_INC=$OPENSSL_PREFIX/include
- OPENSSL_VER=1.0.2h
- OPENSSL_VER=1.0.2j
- LD_LIBRARY_PATH=$LUAJIT_LIB:$LD_LIBRARY_PATH
- TEST_NGINX_SLEEP=0.006
- TEST_NGINX_SLEEP=0.005
- TEST_NGINX_RANDOMIZE=1
matrix:
- NGINX_VERSION=1.9.15
# - NGINX_VERSION=1.10.0
- NGINX_VERSION=1.11.2

before_install:
- sudo luarocks install luacheck
- luacheck -q .
- '! grep -n -P ''(?<=.{80}).+'' --color `find . -name ''*.lua''` || (echo "ERROR: Found Lua source lines exceeding 80 columns." > /dev/stderr; exit 1)'
- '! grep -n -P ''\t+'' --color `find . -name ''*.lua''` || (echo "ERROR: Cannot use tabs." > /dev/stderr; exit 1)'
- sudo cpanm --notest Test::Nginx > build.log 2>&1 || (cat build.log && exit 1)

install:
- if [ ! -d download-cache ]; then mkdir download-cache; fi
- if [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -O download-cache/openssl-$OPENSSL_VER.tar.gz https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz; fi
- sudo apt-get install -qq -y cpanminus axel
- sudo cpanm --notest Test::Nginx > build.log 2>&1 || (cat build.log && exit 1)
- if [ ! -f download-cache/pcre-$PCRE_VER.tar.gz ]; then wget -P download-cache http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-$PCRE_VER.tar.gz; fi
- wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
- git clone https://github.com/openresty/openresty.git ../openresty
- git clone https://github.com/openresty/nginx-devel-utils.git
- git clone https://github.com/openresty/openresty-devel-utils.git
- git clone https://github.com/simpl/ngx_devel_kit.git ../ndk-nginx-module
- git clone https://github.com/openresty/lua-nginx-module.git ../lua-nginx-module
- git clone https://github.com/openresty/no-pool-nginx.git ../no-pool-nginx
Expand All @@ -48,27 +63,29 @@ install:
- git clone https://github.com/openresty/headers-more-nginx-module.git ../headers-more-nginx-module
- git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git
- git clone https://github.com/openresty/mockeagain.git
- git clone https://github.com/openresty/test-nginx.git

script:
- cd luajit2/
- make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT' > build.log 2>&1 || (cat build.log && exit 1)
- make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT -msse4.2' > build.log 2>&1 || (cat build.log && exit 1)
- sudo make install PREFIX=$LUAJIT_PREFIX > build.log 2>&1 || (cat build.log && exit 1)
- cd ..
- cd lua-resty-lrucache && sudo make DESTDIR=$LUAJIT_PREFIX LUA_LIB_DIR=/share/lua/5.1 install && cd ..
- tar zxf download-cache/openssl-$OPENSSL_VER.tar.gz
- cd openssl-$OPENSSL_VER/
- wget https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-$OPENSSL_VER-sess_set_get_cb_yield.patch
- patch -p1 < openssl-$OPENSSL_VER-sess_set_get_cb_yield.patch
- if [ ! -f openssl-1.0.2h-sess_set_get_cb_yield.patch ]; then wget -O openssl-1.0.2h-sess_set_get_cb_yield.patch https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-1.0.2h-sess_set_get_cb_yield.patch; fi
- patch -p1 < openssl-1.0.2h-sess_set_get_cb_yield.patch
- ./config shared --prefix=$OPENSSL_PREFIX -DPURIFY > build.log 2>&1 || (cat build.log && exit 1)
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
- sudo make PATH=$PATH install_sw > build.log 2>&1 || (cat build.log && exit 1)
- cd ../mockeagain/ && make CC=$CC -j$JOBS && cd ..
- export PATH=$PWD/work/nginx/sbin:$PWD/nginx-devel-utils:$PATH
- tar zxf download-cache/pcre-$PCRE_VER.tar.gz
- export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH
- export LD_PRELOAD=$PWD/mockeagain/mockeagain.so
- export LD_LIBRARY_PATH=$PWD/mockeagain:$LD_LIBRARY_PATH
- export TEST_NGINX_RESOLVER=8.8.4.4
- export NGX_BUILD_CC=$CC
- ngx-build $NGINX_VERSION --with-ipv6 --with-http_realip_module --with-http_ssl_module --with-cc-opt="-I$OPENSSL_INC" --with-ld-opt="-L$OPENSSL_LIB -Wl,-rpath,$OPENSSL_LIB" --add-module=../ndk-nginx-module --add-module=../echo-nginx-module --add-module=../headers-more-nginx-module --add-module=../lua-nginx-module --with-debug > build.log 2>&1 || (cat build.log && exit 1)
- ngx-build $NGINX_VERSION --with-ipv6 --with-http_realip_module --with-http_ssl_module --with-pcre=../../pcre-$PCRE_VER --with-pcre-jit --with-cc-opt="-I$OPENSSL_INC" --with-ld-opt="-L$OPENSSL_LIB -Wl,-rpath,$OPENSSL_LIB" --add-module=../ndk-nginx-module --add-module=../echo-nginx-module --add-module=../headers-more-nginx-module --add-module=../lua-nginx-module --with-debug > build.log 2>&1 || (cat build.log && exit 1)
- nginx -V
- ldd `which nginx`|grep -E 'luajit|ssl|pcre'
- prove -r t
- prove -Itest-nginx/lib -j$JOBS -r t
42 changes: 39 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Table of Contents
* [ngx.balancer](#ngxbalancer)
* [ngx.ssl](#ngxssl)
* [ngx.ssl.session](#ngxsslsession)
* [ngx.re](#ngxre)
* [ngx.process](#ngxprocess)
* [ngx.errlog](#ngxerrlog)
* [Caveat](#caveat)
* [TODO](#todo)
* [Author](#author)
Expand Down Expand Up @@ -83,8 +86,12 @@ and requirements.
Prerequisites
=============

**WARNING** This library is included with every OpenResty release. You should use the bundled version
of this library in the particular OpenResty release you are using. Otherwise you may run
into serious comaptibility issues.

* LuaJIT 2.1 (for now, it is the v2.1 git branch in the official luajit-2.0 git repository: http://luajit.org/download.html )
* [ngx_lua](https://github.com/openresty/lua-nginx-module) v0.10.6 or later.
* [ngx_lua](https://github.com/openresty/lua-nginx-module) v0.10.9 or later.
* [lua-resty-lrucache](https://github.com/openresty/lua-resty-lrucache)

[Back to TOC](#table-of-contents)
Expand Down Expand Up @@ -235,6 +242,35 @@ See the [documentation](./lib/ngx/ssl/session.md) for this Lua module for more d

[Back to TOC](#table-of-contents)

## ngx.re

This Lua module provides a Lua API which implements convenience utilities for
the `ngx.re` API.

See the [documentation](./lib/ngx/re.md) for this Lua module for more details.

[Back to TOC](#table-of-contents)

## ngx.process

This Lua module is used to manage the nginx process in Lua.

See the [documentation](./lib/ngx/process.md) for this Lua module for more details.

This module was first introduced in lua-resty-core v0.1.12.

[Back to TOC](#table-of-contents)

## ngx.errlog

This Lua module provides Lua API to capture and manage nginx error log messages.

See the [documentation](./lib/ngx/errlog.md) for this Lua module for more details.

This module was first introduced in lua-resty-core v0.1.12.

[Back to TOC](#table-of-contents)

Caveat
======

Expand All @@ -256,7 +292,7 @@ TODO
Author
======

Yichun "agentzh" Zhang (章亦春) <[email protected]>, CloudFlare Inc.
Yichun "agentzh" Zhang (章亦春) <[email protected]>, OpenResty Inc.

[Back to TOC](#table-of-contents)

Expand All @@ -265,7 +301,7 @@ Copyright and License

This module is licensed under the BSD license.

Copyright (C) 2013-2016, by Yichun "agentzh" Zhang, CloudFlare Inc.
Copyright (C) 2013-2017, by Yichun "agentzh" Zhang, OpenResty Inc.

All rights reserved.

Expand Down
10 changes: 10 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name=lua-resty-core
abstract=New FFI-based Lua API for the ngx_lua module
author=Yichun "agentzh" Zhang (agentzh)
is_original=yes
license=2bsd
lib_dir=lib
doc_dir=lib
repo_link=https://github.com/openresty/lua-resty-core
main_module=lib/resty/core/base.lua
requires = luajit >= 2.1.0, nginx >= 1.11.2, ngx_http_lua = 0.10.9, openresty/lua-resty-lrucache >= 0.06
10 changes: 5 additions & 5 deletions lib/ngx/balancer.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ Description
===========

This Lua module provides API functions to allow defining highly dynamic NGINX load balancers for
any existing nginx upstream modules like [http://nginx.org/en/docs/http/ngx_http_proxy_module.html ngx_proxy] and
[http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html ngx_fastcgi].
any existing nginx upstream modules like [ngx_proxy](http://nginx.org/en/docs/http/ngx_http_proxy_module.html) and
[ngx_fastcgi](http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html).

It allows you to dynamically select a backend peer to connect to (or retry) on a per-request
basis from a list of backend peers which may also be dynamic.
Expand Down Expand Up @@ -173,7 +173,7 @@ Zero and negative timeout values are not allowed.

You can specify millisecond precision in the timeout values by using floating point numbers like 0.001 (which means 1ms).

Returns `true` when the operation is successul; returns `nil` and a string describing the error
Returns `true` when the operation is successful; returns `nil` and a string describing the error
otherwise.

This only affects the current downstream request. It is not a global change.
Expand Down Expand Up @@ -216,7 +216,7 @@ Please report bugs or submit patches by
Author
======

Yichun Zhang &lt;[email protected]&gt; (agentzh), CloudFlare Inc.
Yichun Zhang &lt;[email protected]&gt; (agentzh), OpenResty Inc.

[Back to TOC](#table-of-contents)

Expand All @@ -225,7 +225,7 @@ Copyright and License

This module is licensed under the BSD license.

Copyright (C) 2015, by Yichun "agentzh" Zhang, CloudFlare Inc.
Copyright (C) 2015-2017, by Yichun "agentzh" Zhang, OpenResty Inc.

All rights reserved.

Expand Down
107 changes: 107 additions & 0 deletions lib/ngx/errlog.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
-- Copyright (C) Yichun Zhang (agentzh)


local ffi = require 'ffi'
local base = require "resty.core.base"
local ffi_string = ffi.string
local get_string_buf = base.get_string_buf
local get_size_ptr = base.get_size_ptr
local C = ffi.C
local new_tab = base.new_tab
local ffi_new = ffi.new
local charpp = ffi_new("char *[1]")
local intp = ffi.new("int[1]")
local num_value = ffi_new("double[1]")
local getfenv = getfenv
local tonumber = tonumber


local _M = { version = base.version }


ffi.cdef[[
int ngx_http_lua_ffi_errlog_set_filter_level(int level, unsigned char *err,
size_t *errlen);
int ngx_http_lua_ffi_errlog_get_msg(char **log, int *loglevel,
unsigned char *err, size_t *errlen, double *log_time);

int ngx_http_lua_ffi_errlog_get_sys_filter_level(ngx_http_request_t *r);
]]


local ERR_BUF_SIZE = 128
local FFI_ERROR = base.FFI_ERROR


function _M.set_filter_level(level)
if not level then
return nil, [[missing "level" argument]]
end

local err = get_string_buf(ERR_BUF_SIZE)
local errlen = get_size_ptr()
errlen[0] = ERR_BUF_SIZE
local rc = C.ngx_http_lua_ffi_errlog_set_filter_level(level, err, errlen)

if rc == FFI_ERROR then
return nil, ffi_string(err, errlen[0])
end

return true
end


function _M.get_logs(max, logs)
local err = get_string_buf(ERR_BUF_SIZE)
local errlen = get_size_ptr()
errlen[0] = ERR_BUF_SIZE

local log = charpp
local loglevel = intp
local log_time = num_value

max = max or 10

if not logs then
logs = new_tab(max * 3 + 1, 0)
end

local count = 0

for i = 1, max do
local loglen = C.ngx_http_lua_ffi_errlog_get_msg(log, loglevel, err,
errlen, log_time)
if loglen == FFI_ERROR then
return nil, ffi_string(err, errlen[0])
end

if loglen > 0 then
logs[count + 1] = loglevel[0]
logs[count + 2] = log_time[0]
logs[count + 3] = ffi_string(log[0], loglen)

count = count + 3
end

if loglen < 0 then -- no error log
logs[count + 1] = nil
break
end

if i == max then -- last one
logs[count + 1] = nil
break
end
end

return logs
end


function _M.get_sys_filter_level()
local r = getfenv(0).__ngx_req
return tonumber(C.ngx_http_lua_ffi_errlog_get_sys_filter_level(r))
end


return _M
Loading