Added logging to stdout
This commit is contained in:
22
config.py
22
config.py
@@ -1,6 +1,24 @@
|
|||||||
import os
|
import logging, os, sys
|
||||||
|
|
||||||
|
# Main config section
|
||||||
class Config:
|
class Config:
|
||||||
|
APP_NAME = "hydrogen"
|
||||||
MAIN_PAGE_TITLE = "Selected poems"
|
MAIN_PAGE_TITLE = "Selected poems"
|
||||||
CONTENT_DIR = os.environ.get('CONTENT_DIR') or 'content'
|
OUTPUT_DIR = os.environ.get('OUTPUT_DIR') or 'public'
|
||||||
HEADER_IMAGE = 'static/header.jpg'
|
HEADER_IMAGE = 'static/header.jpg'
|
||||||
|
LOG_TO = sys.stdout
|
||||||
|
LOG_LEVEL = logging.DEBUG
|
||||||
|
|
||||||
|
# Logging config section
|
||||||
|
logger = logging.getLogger(Config.APP_NAME)
|
||||||
|
logger.setLevel(Config.LOG_LEVEL)
|
||||||
|
stdout_handler = logging.StreamHandler(Config.LOG_TO)
|
||||||
|
stdout_handler.setLevel(Config.LOG_LEVEL)
|
||||||
|
formatter = logging.Formatter(
|
||||||
|
'[%(asctime)s] %(name)s: %(levelname)s: %(message)s',
|
||||||
|
datefmt='%Y-%m-%d %H:%M:%S'
|
||||||
|
)
|
||||||
|
stdout_handler.setFormatter(formatter)
|
||||||
|
if not logger.hasHandlers():
|
||||||
|
logger.addHandler(stdout_handler)
|
||||||
|
logger.propagate = False
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import frontmatter
|
import frontmatter
|
||||||
import markdown
|
import markdown
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
import shutil
|
import shutil
|
||||||
from config import Config
|
from config import Config, logger
|
||||||
|
|
||||||
content_dir = Path('content')
|
content_dir = Path('content')
|
||||||
template_dir = Path('templates')
|
template_dir = Path('templates')
|
||||||
output_dir = Path('public')
|
output_dir = Path(Config.OUTPUT_DIR)
|
||||||
img_dir = Path('public/images')
|
img_dir = Path('public/images')
|
||||||
assets_dir = Path('public/assets')
|
assets_dir = Path('public/assets')
|
||||||
assets_css_dir = Path('public/assets/css')
|
assets_css_dir = Path('public/assets/css')
|
||||||
@@ -88,3 +90,5 @@ about_content.render_content()
|
|||||||
|
|
||||||
# Move 'robots.txt' into output_dir
|
# Move 'robots.txt' into output_dir
|
||||||
shutil.copyfile(static_dir / 'robots.txt', output_dir / 'robots.txt')
|
shutil.copyfile(static_dir / 'robots.txt', output_dir / 'robots.txt')
|
||||||
|
|
||||||
|
logger.info(f"Created {len(content_items)} content items.")
|
||||||
Reference in New Issue
Block a user