2121from typing import Any , Dict , List , Union , Sequence , Tuple
2222
2323import can
24+ from can .io import BaseRotatingLogger
25+ from can .io .generic import MessageWriter
2426from . import Bus , BusState , Logger , SizedRotatingLogger
2527from .typechecking import CanFilter , CanFilters
2628
@@ -61,10 +63,10 @@ def _create_base_argument_parser(parser: argparse.ArgumentParser) -> None:
6163 parser .add_argument (
6264 "extra_args" ,
6365 nargs = argparse .REMAINDER ,
64- help = r "The remaining arguments will be used for the interface "
65- r" initialisation. For example, `-i vector -c 1 --app-name= "
66- r"MyCanApp` is the equivalent to opening the bus with `Bus( "
67- r" 'vector', channel=1, app_name='MyCanApp')" ,
66+ help = "The remaining arguments will be used for the interface and "
67+ "logger/player initialisation. "
68+ "For example, `-i vector -c 1 --app-name=MyCanApp` is the equivalent "
69+ "to opening the bus with `Bus( 'vector', channel=1, app_name='MyCanApp')" ,
6870 )
6971
7072
@@ -224,7 +226,7 @@ def main() -> None:
224226 raise SystemExit (errno .EINVAL )
225227
226228 results , unknown_args = parser .parse_known_args ()
227- additional_config = _parse_additional_config (unknown_args )
229+ additional_config = _parse_additional_config ([ * results . extra_args , * unknown_args ] )
228230 bus = _create_bus (results , can_filters = _parse_filters (results ), ** additional_config )
229231
230232 if results .active :
@@ -235,13 +237,20 @@ def main() -> None:
235237 print (f"Connected to { bus .__class__ .__name__ } : { bus .channel_info } " )
236238 print (f"Can Logger (Started on { datetime .now ()} )" )
237239
238- options = { "append" : results . append }
240+ logger : Union [ MessageWriter , BaseRotatingLogger ]
239241 if results .file_size :
240242 logger = SizedRotatingLogger (
241- base_filename = results .log_file , max_bytes = results .file_size , ** options
243+ base_filename = results .log_file ,
244+ max_bytes = results .file_size ,
245+ append = results .append ,
246+ ** additional_config ,
242247 )
243248 else :
244- logger = Logger (filename = results .log_file , ** options ) # type: ignore
249+ logger = Logger (
250+ filename = results .log_file ,
251+ append = results .append ,
252+ ** additional_config ,
253+ )
245254
246255 try :
247256 while True :
0 commit comments