Fix pythonw logging handler crashes and reduce noisy dependency logs
This commit is contained in:
1 parent
3e4ce93824
commit
c0ebe118cb
2 files changed
+41
-2
No files matched your search
+20
-1
@@ -25,7 +25,26 @@ except Exception as gui_import_error:
|
||||
print("Then run: pip install -r requirements.txt")
|
||||
sys.exit(1)
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
def configure_logging():
|
||||
"""Configure logging with safe handlers for pythonw/GUI environments."""
|
||||
log_format = '%(asctime)s - %(levelname)s - %(message)s'
|
||||
handlers = []
|
||||
|
||||
try:
|
||||
handlers.append(logging.FileHandler('app_log.txt', encoding='utf-8'))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
stream = getattr(sys, 'stderr', None) or getattr(sys, 'stdout', None)
|
||||
if stream is not None:
|
||||
handlers.append(logging.StreamHandler(stream))
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format=log_format, handlers=handlers, force=True)
|
||||
for noisy_logger in ('webdriver_manager', 'matplotlib', 'urllib3', 'plexapi'):
|
||||
logging.getLogger(noisy_logger).setLevel(logging.WARNING)
|
||||
|
||||
|
||||
configure_logging()
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Config:
|
||||
|
||||
Reference in new issue
Block a user