diff options
Diffstat (limited to 'src/caelestia/utils/logging.py')
| -rw-r--r-- | src/caelestia/utils/logging.py | 20 |
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 |