Add RichHandler for logging
This commit is contained in:
parent
a3c949c7d5
commit
49932539da
2 changed files with 14 additions and 4 deletions
|
@ -4,6 +4,7 @@ from pathlib import Path
|
|||
|
||||
from photoalbum.config import DEFAULT_CONFIG_PATH, Config
|
||||
from photoalbum.generate import generate
|
||||
from rich.logging import RichHandler
|
||||
|
||||
logger = logging.getLogger("photoalbum.cli")
|
||||
|
||||
|
@ -91,10 +92,17 @@ def parse_args() -> Namespace:
|
|||
return parser.parse_args()
|
||||
|
||||
|
||||
def setup_logging(level: str) -> None:
|
||||
def setup_logging(level_str: str) -> None:
|
||||
levels = logging.getLevelNamesMapping()
|
||||
# TODO: Set up a better formatter with date/time and stuff
|
||||
logging.basicConfig(level=levels[level.upper()])
|
||||
level = levels[level_str.upper()]
|
||||
logging.basicConfig(
|
||||
level=level,
|
||||
handlers=[RichHandler(rich_tracebacks=True)],
|
||||
)
|
||||
# Override PIL logging because debug is really noisy
|
||||
if level <= logging.DEBUG:
|
||||
logging.getLogger("PIL").setLevel(logging.INFO)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -14,7 +14,7 @@ def generate(config: Config, album_path: Path) -> None:
|
|||
Main generation function
|
||||
"""
|
||||
skel_files_created, skel_files = maybe_create_skeleton(config, album_path)
|
||||
# generate_thumbnails(config, album_path)
|
||||
generate_thumbnails(config, album_path)
|
||||
# generate_html(config, album_path)
|
||||
|
||||
if skel_files_created:
|
||||
|
@ -82,11 +82,13 @@ def generate_thumbnails(config: Config, path: Path) -> None:
|
|||
thumb_img.thumbnail(config.thumbnail_size)
|
||||
thumb_filename = file_path.stem + ".thumb" + file_path.suffix
|
||||
thumb_img.save(slides_path / thumb_filename)
|
||||
logger.info(f"Generated thumbnail size {parent_path / filename} -> {thumb_filename}")
|
||||
|
||||
screen_img = orig_img.copy()
|
||||
screen_img.thumbnail(config.view_size)
|
||||
screen_filename = file_path.stem + ".screen" + file_path.suffix
|
||||
screen_img.save(slides_path / screen_filename)
|
||||
logger.info(f"Generated screen size {parent_path / filename} -> {screen_filename}")
|
||||
|
||||
|
||||
def generate_html(config: Config, path: Path) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue