/tutorial/io/redirection_example.e
Specman e | 29 lines | 23 code | 3 blank | 3 comment | 1 complexity | 86f7bdc20c51fa687976b56d2a8559f1 MD5 | raw file
1class REDIRECTION_EXAMPLE 2 -- 3 -- Shows how to redirect `std_input_stream', `std_output_stream' and `std_error_stream'. 4 -- 5 6create {ANY} 7 make 8 9feature {} 10 make 11 local 12 log_name: STRING; log_file: TEXT_FILE_WRITE 13 do 14 log_name := "redirection_example.log" 15 io.put_string("Output redirected on %"" + log_name + "%".%N") 16 create log_file.connect_to(log_name) 17 if log_file.is_connected then 18 standard_streams.set_std_output(log_file) 19 standard_streams.std_output.put_string("This is not on the screen!%N") 20 log_file.put_string("This is not on the screen!%N") 21 standard_streams.restore_std_output 22 log_file.disconnect 23 standard_streams.std_output.put_string("Do not forget to remove the %"" + log_name + "%" file.%N") 24 else 25 std_output.put_string("Cannot write %"" + log_name + "%" in the current working directory.%N") 26 end 27 end 28 29end -- class REDIRECTION_EXAMPLE