Seregon/PkgToolBox

Toolbox for analyzing and editing pkg application files for psp,ps3, ps4 and ps5, includes the most useful functions you might need.

Python/57.3 KB/No license
Utilities/Logger.py
PkgToolBox / Utilities / Logger.py
1import logging
2import sys
3
4class Logger:
5 @staticmethod
6 def setup_logger():
7 logging.basicConfig(filename='PS4PKGToolLog.txt', level=logging.DEBUG,
8 format='%(asctime)s - %(levelname)s: %(message)s',
9 datefmt='%Y-%m-%d %H:%M:%S')
10 console = logging.StreamHandler(sys.stdout)
11 console.setLevel(logging.INFO)
12 formatter = logging.Formatter('%(levelname)s: %(message)s')
13 console.setFormatter(formatter)
14 logging.getLogger('').addHandler(console)
15
16 @staticmethod
17 def log_information(message):
18 try:
19 logging.info(message)
20 except Exception as e:
21 logging.error(f"Error in logging: {str(e)}")
22
23 @staticmethod
24 def log_error(message):
25 try:
26 logging.error(message)
27 except Exception as e:
28 logging.error(f"Error in logging: {str(e)}")
29
30 @staticmethod
31 def log_warning(message):
32 try:
33 logging.warning(message)
34 except Exception as e:
35 logging.error(f"Error in logging: {str(e)}")