mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-22 02:50:15 +10:00
logging: Add milliseconds to log file name
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
- Implement formatted logging
|
- Implement formatted logging
|
||||||
- Allowing easier debugging
|
- Allowing easier debugging
|
||||||
- Implement per-version, per-run file logging
|
- Implement per-version, per-run file logging
|
||||||
- ex. OpenCore-Patcher (0.6.7) (2021-12-31-12-34-56).log
|
- ex. OpenCore-Patcher (0.6.7) (2021-12-31-12-34-56-666903).log
|
||||||
- Keep only 10 latest log files
|
- Keep only 10 latest log files
|
||||||
- Reveal log file in Finder on main thread crash
|
- Reveal log file in Finder on main thread crash
|
||||||
- Avoid writing username to log file
|
- Avoid writing username to log file
|
||||||
|
|||||||
@@ -82,8 +82,9 @@ class GlobalEnviromentSettings:
|
|||||||
# delete defaults plist
|
# delete defaults plist
|
||||||
try:
|
try:
|
||||||
Path(defaults_path).unlink()
|
Path(defaults_path).unlink()
|
||||||
except PermissionError:
|
except Exception as e:
|
||||||
logging.info("Permission error: Unable to delete defaults plist")
|
logging.error("Error: Unable to delete defaults plist")
|
||||||
|
logging.error(e)
|
||||||
|
|
||||||
|
|
||||||
def _fix_file_permission(self) -> None:
|
def _fix_file_permission(self) -> None:
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
import pprint
|
import pprint
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
@@ -9,8 +8,9 @@ import subprocess
|
|||||||
import applescript
|
import applescript
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from resources import constants, analytics_handler
|
from resources import constants, analytics_handler, global_settings
|
||||||
|
|
||||||
|
|
||||||
class InitializeLoggingSupport:
|
class InitializeLoggingSupport:
|
||||||
@@ -36,7 +36,9 @@ class InitializeLoggingSupport:
|
|||||||
def __init__(self, global_constants: constants.Constants) -> None:
|
def __init__(self, global_constants: constants.Constants) -> None:
|
||||||
self.constants: constants.Constants = global_constants
|
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.log_filepath: Path = None
|
||||||
|
|
||||||
self.original_excepthook: sys = sys.excepthook
|
self.original_excepthook: sys = sys.excepthook
|
||||||
@@ -220,6 +222,13 @@ class InitializeLoggingSupport:
|
|||||||
error_msg += f"{type.__name__}: {value}"
|
error_msg += f"{type.__name__}: {value}"
|
||||||
if tb:
|
if tb:
|
||||||
error_msg += f"\n\n{traceback.extract_tb(tb)[-1]}"
|
error_msg += f"\n\n{traceback.extract_tb(tb)[-1]}"
|
||||||
|
|
||||||
|
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?"
|
error_msg += "\n\nSend crash report to Dortania?"
|
||||||
|
|
||||||
# Ask user if they want to send crash report
|
# Ask user if they want to send crash report
|
||||||
@@ -232,6 +241,10 @@ class InitializeLoggingSupport:
|
|||||||
if result[applescript.AEType(b'bhit')] != "Yes":
|
if result[applescript.AEType(b'bhit')] != "Yes":
|
||||||
return
|
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()
|
threading.Thread(target=analytics_handler.Analytics(self.constants).send_crash_report, args=(self.log_filepath,)).start()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user