diff options
author | crownedgrouse <[email protected]> | 2013-07-13 23:58:44 +0200 |
---|---|---|
committer | crownedgrouse <[email protected]> | 2013-07-13 23:58:44 +0200 |
commit | d42e6f24eec74299253039f969b69c532877ceb9 (patch) | |
tree | d324a1ea72a13a17ac5f28fc6b1382d16dd05d94 /lib/sasl/test | |
parent | bc30159f5eac936fa9c8ea97d2ab11564448ba7b (diff) | |
download | otp-d42e6f24eec74299253039f969b69c532877ceb9.tar.gz otp-d42e6f24eec74299253039f969b69c532877ceb9.tar.bz2 otp-d42e6f24eec74299253039f969b69c532877ceb9.zip |
Add Fd usage in rb logging
rb was only accepting physical filenames as log file.
This patch allow rb to accept now any io_device, valid registered name,
except standard_error which is replaced by standard_io.
Creation of two new exported functions : rb:log_list/0-1
that print in log file if existing, otherwise on standard_io.
Add new functions documentation and tests in rb_SUITE.
Diffstat (limited to 'lib/sasl/test')
-rw-r--r-- | lib/sasl/test/rb_SUITE.erl | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/sasl/test/rb_SUITE.erl b/lib/sasl/test/rb_SUITE.erl index b0e43be3a2..453f992850 100644 --- a/lib/sasl/test/rb_SUITE.erl +++ b/lib/sasl/test/rb_SUITE.erl @@ -362,18 +362,48 @@ start_stop_log(Config) -> StdioResult = [_|_] = capture(fun() -> rb:show(1) end), {ok,<<>>} = file:read_file(OutFile), - %% Start log and check that show is printed to log and not to standad_io + %% Start log and check that show is printed to log and not to standard_io ok = rb:start_log(OutFile), [] = capture(fun() -> rb:show(1) end), {ok,Bin} = file:read_file(OutFile), true = (Bin =/= <<>>), + %% Start log with atom standard_io and check that show is printed to standard_io + ok = rb:stop_log(), + ok = file:write_file(OutFile,[]), + ok = rb:start_log(standard_io), + StdioResult = [_|_] = capture(fun() -> rb:show(1) end), + {ok,<<>>} = file:read_file(OutFile), + + %% Start log and check that show is printed to iodevice log and not to standard_io + ok = rb:stop_log(), + ok = file:write_file(OutFile,[]), + {ok, IoOutFile} = file:open(OutFile,[write]), + ok = rb:start_log(IoOutFile), + [] = capture(fun() -> rb:show(1) end), + {ok,Bin} = file:read_file(OutFile), + true = (Bin =/= <<>>), + ok = file:close(IoOutFile), + %% Stop log and check that show is printed to standard_io and not to log ok = rb:stop_log(), ok = file:write_file(OutFile,[]), StdioResult = capture(fun() -> rb:show(1) end), {ok,<<>>} = file:read_file(OutFile), + %% Start log and check that list is printed to log and not to standard_io + ok = file:write_file(OutFile,[]), + ok = rb:start_log(OutFile), + [] = capture(fun() -> rb:log_list() end), + {ok,Bin2} = file:read_file(OutFile), + true = (Bin2 =/= <<>>), + + %% Stop log and check that list is printed to standard_io and not to log + ok = rb:stop_log(), + ok = file:write_file(OutFile,[]), + StdioResult2 = capture(fun() -> rb:log_list() end), + {ok,<<>>} = file:read_file(OutFile), + %% Test that standard_io is used if log file can not be opened ok = rb:start_log(filename:join(nonexistingdir,"newfile.txt")), StdioResult = capture(fun() -> rb:show(1) end), |