diff --git a/songbook b/songbook index 20392cf4..1dc98586 100755 --- a/songbook +++ b/songbook @@ -76,7 +76,7 @@ def main(): # Logging configuration logging.basicConfig(name='songbook', level=logging.INFO) - logger = logging.getLogger('songbook') + logger = logging.getLogger(__name__) # set script locale to match user's try: @@ -105,7 +105,7 @@ def main(): songbook['datadir'] = os.path.dirname(songbook_path) try: - sb_builder = SongbookBuilder(songbook, basename, logger=logger) + sb_builder = SongbookBuilder(songbook, basename) sb_builder.interactive = True sb_builder.unsafe = True diff --git a/songbook_core/build.py b/songbook_core/build.py index 850bb833..75e1d00e 100644 --- a/songbook_core/build.py +++ b/songbook_core/build.py @@ -5,6 +5,7 @@ import codecs import glob +import logging import os.path import re from subprocess import Popen, PIPE, call @@ -16,6 +17,7 @@ from songbook_core.index import process_sxd from songbook_core.songs import Song, SongsList from songbook_core.templates import TexRenderer +LOGGER = logging.getLogger(__name__) EOL = "\n" DEFAULT_AUTHWORDS = { "after": ["by"], @@ -152,13 +154,11 @@ class SongbookBuilder(object): # are function; values are return values of functions. _called_functions = {} - def __init__(self, raw_songbook, basename, logger=None): + def __init__(self, raw_songbook, basename): # Representation of the .sb songbook configuration file. self.songbook = Songbook(raw_songbook, basename) # Basename of the songbook to be built. self.basename = basename - # logging object to use - self.logger = logger def _run_once(self, function, *args, **kwargs): """Run function if it has not been run yet. @@ -237,7 +237,7 @@ class SongbookBuilder(object): while line: log += line line = p.stdout.readline() - self.logger.info(log) + LOGGER.info(log) if p.returncode: raise errors.LatexCompilationError(self.basename) @@ -246,8 +246,7 @@ class SongbookBuilder(object): """Make index""" sxd_files = glob.glob("%s_*.sxd" % self.basename) for sxd_file in sxd_files: - if self.logger: - self.logger.info("processing " + sxd_file) + LOGGER.info("processing " + sxd_file) idx = process_sxd(sxd_file) with open(sxd_file[:-3] + "sbx", "w") as index_file: index_file.write(idx.entries_to_str().encode('utf8'))