11import argparse
22import datetime
33import logging
4+ import logging .handlers as handlers
45import urllib .parse
5- from .version import __version__
6+ from mllp_http_https .version import __version__
67
78
89class ArgumentFormatter (
@@ -135,6 +136,7 @@ def http2mllp():
135136 pass
136137
137138
139+
138140def mllp2http ():
139141 parser = argparse .ArgumentParser (
140142 "mllp2http" ,
@@ -233,7 +235,7 @@ def https2mllp():
233235 )
234236 parser .add_argument (
235237 "--mllp_port" ,
236- default = 2575 ,
238+ default = " 2575" ,
237239 type = int ,
238240 help = "MLLP PORT" ,
239241 )
@@ -274,9 +276,9 @@ def https2mllp():
274276 default = "info" ,
275277 )
276278 parser .add_argument (
277- "--log-file " ,
279+ "--log-folder " ,
278280 default = None ,
279- help = "Path to file where the logs will be placed. If not provided logging will be done on command window."
281+ help = "Path to folder where the logs will be placed. If not provided logging will be done on command window."
280282 )
281283 parser .add_argument (
282284 "--mllp-keep-alive" ,
@@ -340,13 +342,24 @@ def https2mllp():
340342
341343 import mllp_http_https .https2mllp
342344
343- # If log_file is provided, logs will be written in file. Otherwise, will be written on console.
344- if args .log_file :
345- logging .basicConfig (
346- filename = args .log_file ,
347- format = "%(asctime)s [%(levelname)s] %(name)s %(message)s" ,
348- level = log_level (args .log_level ),
345+ # If log_folder is provided, logs will be written in file. Otherwise, will be written on console.
346+ if args .log_folder :
347+ import mllp_http_https .log2file
348+ log = mllp_http_https .log2file .Log2File (
349+ file_name = "https2mllp.log" ,
350+ folder_path = args .log_folder ,
351+ log_level_str = args .log_level ,
352+ number_of_days_log = 1 ,
353+ )
354+ log .new_log ()
355+
356+ # Start additional thread to delete old logs
357+ log_monitor = mllp_http_https .log2file .LogMonitor (
358+ number_of_days_check = 30 ,
359+ folder_path = args .log_folder ,
349360 )
361+ log_monitor .start ()
362+
350363 else :
351364 logging .basicConfig (
352365 format = "%(asctime)s [%(levelname)s] %(name)s %(message)s" ,
@@ -370,6 +383,7 @@ def https2mllp():
370383 )
371384
372385 try :
386+ # Start the serving on the main thread
373387 mllp_http_https .https2mllp .serve (
374388 address = (
375389 args .host ,
@@ -435,9 +449,9 @@ def mllp2https():
435449 default = "info" ,
436450 )
437451 parser .add_argument (
438- "--log-file " ,
452+ "--log-folder " ,
439453 default = None ,
440- help = "Path to file where the logs will be placed. If not provided logging will be done on command window."
454+ help = "Path to folder where the logs will be placed. If not provided logging will be done on command window."
441455 )
442456 parser .add_argument (
443457 "--mllp-release" ,
@@ -466,13 +480,29 @@ def mllp2https():
466480
467481 import mllp_http_https .mllp2https
468482
469- # If log_file is provided, logs will be written in file. Otherwise, will be written on console.
470- if args .log_file :
471- logging .basicConfig (
472- filename = args .log_file ,
473- format = "%(asctime)s [%(levelname)s] %(name)s %(message)s" ,
474- level = log_level (args .log_level ),
483+ # If log_folder is provided, logs will be written in file. Otherwise, will be written on console.
484+ if args .log_folder :
485+ import mllp_http_https .log2file
486+ log = mllp_http_https .log2file .Log2File (
487+ file_name = "mllp2https.log" ,
488+ folder_path = args .log_folder ,
489+ log_level_str = args .log_level ,
490+ number_of_days_log = 1 ,
475491 )
492+ log .new_log ()
493+
494+ # Start additional thread to delete old logs
495+ log_monitor = mllp_http_https .log2file .LogMonitor (
496+ number_of_days_check = 30 ,
497+ folder_path = args .log_folder ,
498+ )
499+ log_monitor .start ()
500+
501+ # logging.basicConfig(
502+ # filename=args.log_file,
503+ # format="%(asctime)s [%(levelname)s] %(name)s %(message)s",
504+ # level=log_level(args.log_level),
505+ # )
476506 else :
477507 logging .basicConfig (
478508 format = "%(asctime)s [%(levelname)s] %(name)s %(message)s" ,
0 commit comments