@@ -58,49 +58,50 @@ def _create_handlers(args):
5858 handlers .handle_error = error_logger .error
5959 output_format = args .output_format
6060 logger_formatter = _get_log_formatter (output_format )
61+ destination_args = _create_destination_args (args )
6162 logger = _get_logger (
62- formatter = logger_formatter ,
63- service_name = _SERVICE_NAME ,
64- destination = args .destination ,
65- destination_type = args .destination_type ,
66- destination_port = int (args .destination_port ),
67- destination_protocol = args .destination_protocol ,
63+ formatter = logger_formatter , service_name = _SERVICE_NAME , destination_args = destination_args
6864 )
6965 handlers .handle_response = _get_response_handler (logger )
7066 return handlers
7167
7268
73- def _get_logger (
74- formatter ,
75- service_name ,
76- destination ,
77- destination_type ,
78- destination_port = 514 ,
79- destination_protocol = "TCP" ,
80- ):
69+ def _create_destination_args (args ):
70+ destination_args = common .DestinationArgs ()
71+ destination_args .destination_type = args .destination_type
72+ destination_args .destination = args .destination
73+ destination_args .destination_port = args .destination_port
74+ destination_args .destination_protocol = args .destination_protocol
75+ return destination_args
76+
77+
78+ def _get_logger (formatter , service_name , destination_args ):
8179 try :
8280 return common .get_logger (
83- formatter = formatter ,
84- service_name = service_name ,
85- destination = destination ,
86- destination_type = destination_type ,
87- destination_port = destination_port ,
88- destination_protocol = destination_protocol ,
81+ formatter = formatter , service_name = service_name , destination_args = destination_args
8982 )
9083 except (herror , gaierror , timeout ) as ex :
9184 print (repr (ex ))
92- print (
93- "Hostname={0}, port={1}, protocol={2}." .format (
94- destination , destination_port , destination_protocol
95- )
96- )
85+ _print_server_args (destination_args )
9786 exit (1 )
9887 except IOError as ex :
9988 print (repr (ex ))
100- print ("File path: {0}." .format (destination ))
89+ if ex .errno == 61 :
90+ _print_server_args (destination_args )
91+ return
92+
93+ print ("File path: {0}." .format (destination_args .destination ))
10194 exit (1 )
10295
10396
97+ def _print_server_args (server_args ):
98+ print (
99+ "Hostname={0}, port={1}, protocol={2}." .format (
100+ server_args .destination , server_args .destination_port , server_args .destination_protocol
101+ )
102+ )
103+
104+
104105def _set_up_cursor_store (record_cursor , clear_cursor , handlers ):
105106 if record_cursor or clear_cursor :
106107 store = AEDCursorStore ()
0 commit comments