summaryrefslogtreecommitdiff
path: root/src/caelestia/utils/logging.py
diff options
context:
space:
mode:
authorsweenu <contact@sweenu.xyz>2025-09-09 05:59:04 +0200
committerGitHub <noreply@github.com>2025-09-09 13:59:04 +1000
commit3319d2ca19aebc48a46064a2d31d795d229307ee (patch)
treec6d138b3ef754de75ccef61cda77e231bb75f747 /src/caelestia/utils/logging.py
parentresizer/pip: account for monitor scale (#51) (diff)
downloadcaelestia-cli-3319d2ca19aebc48a46064a2d31d795d229307ee.tar.gz
caelestia-cli-3319d2ca19aebc48a46064a2d31d795d229307ee.tar.bz2
caelestia-cli-3319d2ca19aebc48a46064a2d31d795d229307ee.zip
theme: continue execution after failure for one theme (#50)
Diffstat (limited to 'src/caelestia/utils/logging.py')
-rw-r--r--src/caelestia/utils/logging.py20
1 files changed, 20 insertions, 0 deletions
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