Skip to content

Commit f710ce5

Browse files
author
tiagoepr
committed
Adaptations for GUI usage
1 parent 525c874 commit f710ce5

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

mllp_http_https/log2file.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class LogMonitor:
4949
def __init__(self, number_of_days_check, folder_path):
5050
self.daemon = Thread(target=self.background_task, args=(number_of_days_check,), daemon=True, name='LogControl')
5151
self.folder_path = folder_path
52+
# >> Substituir a thread por um windows service? https://stackoverflow.com/questions/32404/how-do-you-run-a-python-script-as-a-service-in-windows
53+
5254

5355
# task that runs at a fixed interval
5456
def background_task(self, interval_days):

mllp_http_https/main.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -483,20 +483,33 @@ def mllp2https():
483483
# If log_folder is provided, logs will be written in file. Otherwise, will be written on console.
484484
if args.log_folder:
485485
import mllp_http_https.log2file
486+
winservice_check = False
487+
log_folder = ''
488+
if '_svc_gui' in args.log_folder:
489+
log_folder = str(args.log_folder).replace('_svc_gui', '')
490+
print('using GUI', log_folder)
491+
winservice_check = True
492+
else:
493+
log_folder = args.log_folder
494+
print('not using GUI', log_folder)
495+
486496
log = mllp_http_https.log2file.Log2File(
487497
file_name="mllp2https.log",
488-
folder_path=args.log_folder,
498+
folder_path=log_folder,
489499
log_level_str=args.log_level,
490500
number_of_days_log=1,
491501
)
492502
log.new_log()
493503

494504
# 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()
505+
# Only used if not in a WinService since it will use a new thread
506+
if not winservice_check:
507+
print('starting monitor')
508+
log_monitor = mllp_http_https.log2file.LogMonitor(
509+
number_of_days_check=30,
510+
folder_path=log_folder,
511+
)
512+
log_monitor.start()
500513

501514
# logging.basicConfig(
502515
# filename=args.log_file,

mllp_http_https/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.2.36"
1+
__version__ = "1.2.37"

0 commit comments

Comments
 (0)