mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 21:02:00 +00:00
Only keep up to 5 recent logs of runs of plugins (#525)
This commit is contained in:
committed by
GitHub
parent
9233495cac
commit
dd130dbbd7
@@ -17,6 +17,7 @@ __version__ = '0.1.0'
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Constants
|
Constants
|
||||||
@@ -117,7 +118,8 @@ Environment variable: `DECKY_PLUGIN_AUTHOR`.
|
|||||||
e.g.: `John Doe`
|
e.g.: `John Doe`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DECKY_PLUGIN_LOG: str = os.path.join(DECKY_PLUGIN_LOG_DIR, "plugin.log")
|
__cur_time = time.strftime("%Y-%m-%d %H.%M.%S")
|
||||||
|
DECKY_PLUGIN_LOG: str = os.path.join(DECKY_PLUGIN_LOG_DIR, f"{__cur_time}.log")
|
||||||
"""
|
"""
|
||||||
The path to the plugin's main logfile.
|
The path to the plugin's main logfile.
|
||||||
Environment variable: `DECKY_PLUGIN_LOG`.
|
Environment variable: `DECKY_PLUGIN_LOG`.
|
||||||
@@ -192,6 +194,12 @@ def migrate_logs(*files_or_directories: str) -> dict[str, str]:
|
|||||||
Logging
|
Logging
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
for x in [entry.name for entry in sorted(os.scandir(DECKY_PLUGIN_LOG_DIR),key=lambda x: x.stat().st_mtime, reverse=True) if entry.name.endswith(".log")][4:]:
|
||||||
|
os.unlink(os.path.join(DECKY_PLUGIN_LOG_DIR, x))
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to delete old logs: {str(e)}")
|
||||||
|
|
||||||
logging.basicConfig(filename=DECKY_PLUGIN_LOG,
|
logging.basicConfig(filename=DECKY_PLUGIN_LOG,
|
||||||
format='[%(asctime)s][%(levelname)s]: %(message)s',
|
format='[%(asctime)s][%(levelname)s]: %(message)s',
|
||||||
force=True)
|
force=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user