mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
[11] add summary output to log
This commit is contained in:
parent
36eaf230b5
commit
0afb243335
4 changed files with 31 additions and 5 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
1.18.2-develop10
|
1.18.2-develop11
|
||||||
|
|
|
@ -279,8 +279,7 @@ class Library(ABC):
|
||||||
self.report_data[collection][other] = []
|
self.report_data[collection][other] = []
|
||||||
self.report_data[collection][other].append(title)
|
self.report_data[collection][other].append(title)
|
||||||
|
|
||||||
with open(self.report_path, "w"): pass
|
yaml = YAML(self.report_path, start_empty=True)
|
||||||
yaml = YAML(self.report_path)
|
|
||||||
yaml.data = self.report_data
|
yaml.data = self.report_data
|
||||||
yaml.save()
|
yaml.save()
|
||||||
|
|
||||||
|
|
|
@ -931,7 +931,7 @@ def get_system_fonts():
|
||||||
return system_fonts
|
return system_fonts
|
||||||
|
|
||||||
class YAML:
|
class YAML:
|
||||||
def __init__(self, path=None, input_data=None, check_empty=False, create=False):
|
def __init__(self, path=None, input_data=None, check_empty=False, create=False, start_empty=False):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.input_data = input_data
|
self.input_data = input_data
|
||||||
self.yaml = ruamel.yaml.YAML()
|
self.yaml = ruamel.yaml.YAML()
|
||||||
|
@ -940,7 +940,7 @@ class YAML:
|
||||||
if input_data:
|
if input_data:
|
||||||
self.data = self.yaml.load(input_data)
|
self.data = self.yaml.load(input_data)
|
||||||
else:
|
else:
|
||||||
if create and not os.path.exists(self.path):
|
if start_empty or (create and not os.path.exists(self.path)):
|
||||||
with open(self.path, 'w'):
|
with open(self.path, 'w'):
|
||||||
pass
|
pass
|
||||||
self.data = {}
|
self.data = {}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import argparse, os, platform, psutil, sys, time, uuid
|
import argparse, os, platform, psutil, sys, time, uuid
|
||||||
|
from collections import Counter
|
||||||
from concurrent.futures import ProcessPoolExecutor
|
from concurrent.futures import ProcessPoolExecutor
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from modules.logs import MyLogger
|
from modules.logs import MyLogger
|
||||||
|
@ -274,6 +275,32 @@ def start(attrs):
|
||||||
version_line = f"Version: {version[0]}"
|
version_line = f"Version: {version[0]}"
|
||||||
if new_version:
|
if new_version:
|
||||||
version_line = f"{version_line} Newest Version: {new_version}"
|
version_line = f"{version_line} Newest Version: {new_version}"
|
||||||
|
try:
|
||||||
|
log_data = {}
|
||||||
|
with open(logger.main_log, encoding="utf-8") as f:
|
||||||
|
for log_line in f:
|
||||||
|
for err_type in ["WARNING", "ERROR", "CRITICAL"]:
|
||||||
|
if f"[{err_type}]" in log_line:
|
||||||
|
log_line = log_line.split("|")[1].strip()
|
||||||
|
if err_type not in log_data:
|
||||||
|
log_data[err_type] = []
|
||||||
|
log_data[err_type].append(log_line)
|
||||||
|
|
||||||
|
for err_type in ["WARNING", "ERROR", "CRITICAL"]:
|
||||||
|
if err_type not in log_data:
|
||||||
|
continue
|
||||||
|
logger.separator(f"{err_type.lower().capitalize()} Summary", space=False, border=False)
|
||||||
|
|
||||||
|
logger.info("")
|
||||||
|
logger.info(f"Count | Message")
|
||||||
|
logger.separator(f"{logger.separating_character * 5}|", space=False, border=False, side_space=False, left=True)
|
||||||
|
for k, v in Counter(log_data[err_type]).most_common():
|
||||||
|
logger.info(f"{v:>5} | {k}")
|
||||||
|
logger.info("")
|
||||||
|
except Failed as e:
|
||||||
|
logger.stacktrace()
|
||||||
|
logger.error(f"Report Error: {e}")
|
||||||
|
|
||||||
logger.separator(f"Finished {start_type}Run\n{version_line}\nFinished: {end_time.strftime('%H:%M:%S %Y-%m-%d')} Run Time: {run_time}")
|
logger.separator(f"Finished {start_type}Run\n{version_line}\nFinished: {end_time.strftime('%H:%M:%S %Y-%m-%d')} Run Time: {run_time}")
|
||||||
logger.remove_main_handler()
|
logger.remove_main_handler()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue