diff options
Diffstat (limited to 'plugin/decky_plugin.py')
| -rw-r--r-- | plugin/decky_plugin.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/plugin/decky_plugin.py b/plugin/decky_plugin.py index 70cfe6ea..35b872a0 100644 --- a/plugin/decky_plugin.py +++ b/plugin/decky_plugin.py @@ -17,6 +17,7 @@ __version__ = '0.1.0' import os import subprocess import logging +import time """ Constants @@ -117,7 +118,8 @@ Environment variable: `DECKY_PLUGIN_AUTHOR`. 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. Environment variable: `DECKY_PLUGIN_LOG`. @@ -192,6 +194,12 @@ def migrate_logs(*files_or_directories: str) -> dict[str, str]: 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, format='[%(asctime)s][%(levelname)s]: %(message)s', force=True) |
