use logging module instead of print().
This commit is contained in:
parent
6534d360c8
commit
05a9955513
2 changed files with 10 additions and 3 deletions
|
@ -12,6 +12,7 @@ import glob
|
|||
import codecs
|
||||
import shutil
|
||||
import hashlib
|
||||
import logging
|
||||
import datetime
|
||||
try:
|
||||
import ConfigParser
|
||||
|
@ -115,9 +116,6 @@ class Post(object):
|
|||
""" generate post html and write to disk """
|
||||
config = Config()
|
||||
|
||||
print("writing {}".format(os.path.join(config.outputdir,
|
||||
self.outfile)))
|
||||
|
||||
# parse front matter
|
||||
re_yaml = re.compile(r'(^---\s*$(?P<yaml>.*?)^---\s*$)'
|
||||
'?(?P<content>.*)', re.M | re.S)
|
||||
|
@ -338,5 +336,6 @@ def write_file(filename, content):
|
|||
:param filename: filename to write to
|
||||
:param content: content to write
|
||||
"""
|
||||
logging.getLogger('blogtopoid').info('writing %s', filename)
|
||||
with codecs.open(filename, 'w', 'utf-8') as afile:
|
||||
afile.write(content)
|
||||
|
|
|
@ -6,6 +6,7 @@ from __future__ import absolute_import
|
|||
import os
|
||||
import sys
|
||||
import codecs
|
||||
import logging
|
||||
try:
|
||||
import ConfigParser
|
||||
except ImportError:
|
||||
|
@ -94,6 +95,13 @@ def generate():
|
|||
"""
|
||||
config = Config()
|
||||
|
||||
# set up logging
|
||||
ch = logging.StreamHandler(sys.stdout)
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
ch.setFormatter(formatter)
|
||||
logging.getLogger('blogtopoid').addHandler(ch)
|
||||
logging.getLogger('blogtopoid').setLevel(logging.DEBUG)
|
||||
|
||||
pages = []
|
||||
for infile in os.listdir(unicode(config.pagesdir)):
|
||||
if os.path.splitext(infile)[1].lower() in config.supported_blogtypes:
|
||||
|
|
Reference in a new issue