mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-21 03:04:31 +10:00
logging: Add milliseconds to log file name
This commit is contained in:
@@ -82,8 +82,9 @@ class GlobalEnviromentSettings:
|
||||
# delete defaults plist
|
||||
try:
|
||||
Path(defaults_path).unlink()
|
||||
except PermissionError:
|
||||
logging.info("Permission error: Unable to delete defaults plist")
|
||||
except Exception as e:
|
||||
logging.error("Error: Unable to delete defaults plist")
|
||||
logging.error(e)
|
||||
|
||||
|
||||
def _fix_file_permission(self) -> None:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import pprint
|
||||
import logging
|
||||
import threading
|
||||
@@ -9,8 +8,9 @@ import subprocess
|
||||
import applescript
|
||||
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
from resources import constants, analytics_handler
|
||||
from resources import constants, analytics_handler, global_settings
|
||||
|
||||
|
||||
class InitializeLoggingSupport:
|
||||
@@ -36,7 +36,9 @@ class InitializeLoggingSupport:
|
||||
def __init__(self, global_constants: constants.Constants) -> None:
|
||||
self.constants: constants.Constants = global_constants
|
||||
|
||||
self.log_filename: str = f"OpenCore-Patcher_{self.constants.patcher_version}_{time.strftime('%Y-%m-%d_%H-%M-%S')}.log"
|
||||
log_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S-%f")
|
||||
|
||||
self.log_filename: str = f"OpenCore-Patcher_{self.constants.patcher_version}_{log_time}.log"
|
||||
self.log_filepath: Path = None
|
||||
|
||||
self.original_excepthook: sys = sys.excepthook
|
||||
@@ -220,7 +222,14 @@ class InitializeLoggingSupport:
|
||||
error_msg += f"{type.__name__}: {value}"
|
||||
if tb:
|
||||
error_msg += f"\n\n{traceback.extract_tb(tb)[-1]}"
|
||||
error_msg += "\n\nSend crash report to Dortania?"
|
||||
|
||||
cant_log: bool = global_settings.GlobalEnviromentSettings().read_property("DisableCrashAndAnalyticsReporting")
|
||||
|
||||
|
||||
if cant_log is True:
|
||||
error_msg += "\n\nReveal log file?"
|
||||
else:
|
||||
error_msg += "\n\nSend crash report to Dortania?"
|
||||
|
||||
# Ask user if they want to send crash report
|
||||
try:
|
||||
@@ -232,6 +241,10 @@ class InitializeLoggingSupport:
|
||||
if result[applescript.AEType(b'bhit')] != "Yes":
|
||||
return
|
||||
|
||||
if cant_log is True:
|
||||
subprocess.run(["open", "--reveal", self.log_filepath])
|
||||
return
|
||||
|
||||
threading.Thread(target=analytics_handler.Analytics(self.constants).send_crash_report, args=(self.log_filepath,)).start()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user