From 3319d2ca19aebc48a46064a2d31d795d229307ee Mon Sep 17 00:00:00 2001 From: sweenu Date: Tue, 9 Sep 2025 05:59:04 +0200 Subject: theme: continue execution after failure for one theme (#50) --- src/caelestia/utils/logging.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/caelestia/utils/logging.py (limited to 'src/caelestia/utils/logging.py') diff --git a/src/caelestia/utils/logging.py b/src/caelestia/utils/logging.py new file mode 100644 index 0000000..2096407 --- /dev/null +++ b/src/caelestia/utils/logging.py @@ -0,0 +1,20 @@ +from time import strftime + + +def log_message(message: str) -> None: + timestamp = strftime("%Y-%m-%d %H:%M:%S") + print(f"[{timestamp}] {message}") + + +def log_exception(func): + """Log exceptions to stdout instead of raising + + Used by the `apply_()` functions so that an exception, when applying + a theme, does not prevent the other themes from being applied. + """ + def wrapper(*args, **kwargs): + try: + func(*args, **kwargs) + except Exception as e: + log_message(f'Error during execution of "{func.__name__}()": {str(e)}') + return wrapper -- cgit v1.2.3-freya