-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from thibaultcha/feat/silent-logging
feat(cluster) 'silent' option to disable logging
- Loading branch information
Showing
2 changed files
with
99 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# vim:set ts=4 sw=4 et fdm=marker: | ||
use Test::Nginx::Socket::Lua; | ||
use t::Util; | ||
|
||
our $HttpConfig = $t::Util::HttpConfig; | ||
|
||
plan tests => repeat_each() * blocks() * 6; | ||
|
||
log_level('debug'); | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
|
||
=== TEST 1: logging enabled by default | ||
--- log_level: debug | ||
--- http_config eval: $::HttpConfig | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local Cluster = require 'resty.cassandra.cluster' | ||
local cluster, err = Cluster.new() | ||
if not cluster then | ||
ngx.log(ngx.ERR, err) | ||
return | ||
end | ||
|
||
cluster:set_peer_down('127.0.0.1') | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
|
||
--- error_log eval | ||
qr{\[warn\] .*? setting host at 127\.0\.0\.1 DOWN} | ||
--- no_error_log | ||
[error] | ||
[info] | ||
[debug] | ||
|
||
|
||
|
||
=== TEST 2: opts.silent disables all logging | ||
--- log_level: debug | ||
--- http_config eval: $::HttpConfig | ||
--- config | ||
location /t { | ||
content_by_lua_block { | ||
local Cluster = require 'resty.cassandra.cluster' | ||
local cluster, err = Cluster.new { | ||
silent = true | ||
} | ||
if not cluster then | ||
ngx.log(ngx.ERR, err) | ||
return | ||
end | ||
|
||
cluster:set_peer_down('127.0.0.1') | ||
} | ||
} | ||
--- request | ||
GET /t | ||
--- response_body | ||
|
||
--- no_error_log | ||
[error] | ||
[warn] | ||
[info] | ||
[debug] |