openresty / test-nginx

Data-driven test scaffold for Nginx C module and OpenResty Lua library development
http://search.cpan.org/dist/Test-Nginx
438 stars 105 forks source link

bug: error_log does not consider error_log_file #106

Open patthiel opened 3 years ago

patthiel commented 3 years ago

I have a test, where I specify a error_log_file section, however, the error_log assertion helper seems to not consider that i am specifying a custom error_log_file, and looks for the default servroot/logs/error.log

=== TEST 1: unauthorized GET
Without the correct headers, our openresty app should smack down this request.
--- log_level: debug
--- error_log_file: /var/log/custom/error.log
--- http_config eval: $::http_config
--- config eval: $::config
--- main_config eval: $::main_config
--- server_name eval: $::server_name
--- tcp_listen: 8080
--- tcp_reply eval
"HTTP/1.0 200\r\n\r\nhello world"
--- request
GET /
--- error_code: 403
--- error_log eval
["error here"]

I found this note in the documentation:

Right now, it will not affect the --- error_log section and etc accordingly.

That seems to note this (limitation?), but I'm confused what the point of having a error_log_file section is if one can't use the error_log methods against the specified custom error.log file.

agentzh commented 3 years ago

@patthiel Yeah, that error_log_file directive is not very useful for general use. It was just a quick hack to allow emitting error logs to special devices like /dev/stderr, IIRC.