@@ -64,8 +64,7 @@ def main():
6464 level = (logging .WARNING , logging .INFO , logging .DEBUG , logging .NOTSET )[
6565 args .verbosity
6666 ]
67- logging .basicConfig (level = logging .INFO )
68- # logging.getLogger('root').setLevel(logging.INFO)
67+ logging .basicConfig (format = "%(levelname)s: %(message)s" , level = logging .INFO )
6968 logging .getLogger ("rfc2217" ).setLevel (level )
7069
7170 # connect to serial port
@@ -75,27 +74,26 @@ def main():
7574 ser .dtr = False
7675 ser .rts = False
7776
78- logging .info (" RFC 2217 TCP/IP to Serial redirector - type Ctrl-C / BREAK to quit" )
77+ logging .info ("RFC 2217 TCP/IP to Serial redirector - type Ctrl-C / BREAK to quit" )
7978
8079 try :
8180 ser .open ()
8281 except serial .SerialException as e :
83- logging .error (" Could not open serial port {}: {}" . format ( ser . name , e ) )
82+ logging .error (f" Could not open serial port { ser . name } : { e } " )
8483 sys .exit (1 )
8584
86- logging .info (" Serving serial port: {}" . format ( ser .name ) )
85+ logging .info (f" Serving serial port: { ser .name } " )
8786 settings = ser .get_settings ()
8887
8988 srv = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
9089 srv .setsockopt (socket .SOL_SOCKET , socket .SO_REUSEADDR , 1 )
9190 srv .bind (("" , args .localport ))
9291 srv .listen (1 )
93- logging .info (f" TCP/IP port: { args .localport } " )
92+ logging .info (f"TCP/IP port: { args .localport } " )
9493
9594 host_ip = socket .gethostbyname (socket .gethostname ())
96- logging .info (
97- f"Waiting for connection ... use the 'rfc2217://{ host_ip } :{ args .localport } ?ign_set_control' as a PORT"
98- )
95+ wait_msg = f"Waiting for connection ... use the 'rfc2217://{ host_ip } :{ args .localport } ?ign_set_control' as a PORT"
96+ logging .info (wait_msg )
9997
10098 while True :
10199 srv .settimeout (5 )
@@ -111,7 +109,7 @@ def main():
111109 logging .info ("Exited with keyboard interrupt" )
112110 break
113111 try :
114- logging .info (f" Connected by { addr [0 ]} :{ addr [1 ]} " )
112+ logging .info (f"Connected by { addr [0 ]} :{ addr [1 ]} " )
115113 client_socket .setsockopt (socket .IPPROTO_TCP , socket .TCP_NODELAY , 1 )
116114 ser .rts = True
117115 ser .dtr = True
@@ -120,7 +118,7 @@ def main():
120118 try :
121119 r .shortcircuit ()
122120 finally :
123- logging .info (" Disconnected" )
121+ logging .info ("Disconnected" )
124122 r .stop ()
125123 client_socket .close ()
126124 ser .dtr = False
@@ -134,7 +132,7 @@ def main():
134132 except socket .error as msg :
135133 logging .error (str (msg ))
136134
137- logging .info (" --- exit ---" )
135+ logging .info ("--- exit ---" )
138136
139137
140138if __name__ == "__main__" :
0 commit comments