diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2022-04-17 19:39:38 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2022-04-17 19:39:38 -0600 |
commit | 6bec182703885761699f6d53bc9034933b03197e (patch) | |
tree | 489ceb8a2223a9e1067e0eabfd91a62d1c7ec051 /src/pyssg/utils.py | |
parent | d2dfa337171fdad8ed48ce95e3b8f91e291423b7 (diff) |
add initial logging capabilities
still need to add logging to rest of the program: builder, database, discovery, page, parser and rest of the pyssg (build part)
Diffstat (limited to 'src/pyssg/utils.py')
-rw-r--r-- | src/pyssg/utils.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/pyssg/utils.py b/src/pyssg/utils.py index 8e5d90e..2194fe1 100644 --- a/src/pyssg/utils.py +++ b/src/pyssg/utils.py @@ -1,6 +1,10 @@ import os import sys import shutil +import logging +from logging import Logger + +log: Logger = logging.getLogger(__name__) def create_dir(path: str, p: bool=False) -> None: @@ -9,20 +13,21 @@ def create_dir(path: str, p: bool=False) -> None: os.makedirs(path) else: os.mkdir(path) - print(f'created directory "{path}"') + log.info('created directory "%s"', path) except FileExistsError: - print(f'directory "{path}" already exists') + log.info('directory "%s" already exists, ignoring', path) def copy_file(src: str, dst: str) -> None: if not os.path.exists(dst): shutil.copy(src, dst) - print(f'copied file "{src}" to "{dst}"') + log.info('copied file "%s" to "%s"', src, dst) else: - print(f'"{dst}" already exists') + log.info('file "%s" already exists, ignoring', dst) def sanity_check_path(path: str) -> None: if '$' in path: - print(f'"$" character found in path: "{path}"; could be due to non-existant env var.') + log.error('"$" character found in path "%s";' + ' could be due to non-existant env var.', path) sys.exit(1) |