Skip to content

Conversation

@leslie-tsang
Copy link
Member

@leslie-tsang leslie-tsang commented Dec 1, 2021

What this PR does / why we need it:

Currently APISIX apisix.core.log test case 6 don't work as expect, this PR fixes it.

Both test case config can pass the prove, which was unexpected.

=== TEST 6: print error log with prefix
--- config
    location /t {
        content_by_lua_block {
            local log = require("apisix.core").log.new("test: ")
            log.error("error log")
            log.warn("warn log")
            log.notice("notice log")
            log.info("info log")
            ngx.say("done")
        }
    }
--- log_level: error
--- request
GET /t
--- error_log
error log
--- no_error_log
test: warn log
test: notice log
test: info log
=== TEST 6: print error log with prefix
--- config
    location /t {
        content_by_lua_block {
            local log = require("apisix.core").log
            log.error("error log")
            log.warn("warn log")
            log.notice("notice log")
            log.info("info log")
            ngx.say("done")
        }
    }
--- log_level: error
--- request
GET /t
--- error_log
error log
--- no_error_log
test: warn log
test: notice log
test: info log

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@leslie-tsang
Copy link
Member Author

@spacewander Could you help me to figure out why this PR can't pass the CI ?

Notice: ed test 'TEST 6: print error log with prefix - pattern "[notice]" should not match any line in error.log but matches line "2021/12/01 07:15:32 [notice] 30313#30313: init wasm vm: wasmtime" (req 0)
# 2021/12/01 07:15:32 [error] 30315#30315: *23 [lua] content_by_lua(nginx.conf:202):4: raw error log, client: 127.0.0.1, server: localhost, request: "GET /t HTTP/1.1", host: "localhost"
# '
#   at /home/runner/work/apisix/apisix/test-nginx/lib/Test/Nginx/Socket.pm line 1280.
# Looks like you failed 1 test of 70.

@leslie-tsang
Copy link
Member Author

@membphis ping

@membphis
Copy link
Member

membphis commented Dec 1, 2021

@leslie-tsang one pr for one thing ^_^

change this PR to smaller

@leslie-tsang leslie-tsang changed the title fix(core.log): optimize code style and fix unit test case fix(core.log): fix unit test case Dec 1, 2021
@leslie-tsang leslie-tsang marked this pull request as ready for review December 2, 2021 01:21
@spacewander spacewander changed the title fix(core.log): fix unit test case test(core.log): fix unit test case Dec 2, 2021
@spacewander spacewander merged commit 9b74906 into apache:master Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants