From c62416fd119b5be57fd03541aac3f392f552e420 Mon Sep 17 00:00:00 2001 From: Simeon Warner Date: Wed, 2 Jul 2014 19:45:26 -0400 Subject: [PATCH] Use hierarchical logger names --- bin/resync | 2 +- resync/client.py | 2 +- resync/client_utils.py | 2 +- resync/dump.py | 7 ++++--- resync/list_base.py | 2 +- resync/mapper.py | 4 ++-- resync/resource_list_builder.py | 2 +- resync/sitemap.py | 2 +- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bin/resync b/bin/resync index a98ed3e..9bfe899 100755 --- a/bin/resync +++ b/bin/resync @@ -156,7 +156,7 @@ def main(): help="override default size limits") # Want these to show at the end opt.add_option('--verbose', '-v', action='store_true', - help="verbose") + help="verbose, show additional informational messages") opt.add_option('--logger', '-l', action='store_true', help="create detailed log of client actions (will write " "to %s unless specified with --logfile" % diff --git a/resync/client.py b/resync/client.py index 63286c6..296d267 100644 --- a/resync/client.py +++ b/resync/client.py @@ -45,7 +45,7 @@ class Client(object): self.checksum = checksum self.verbose = verbose self.dryrun = dryrun - self.logger = logging.getLogger('client') + self.logger = logging.getLogger('resync.client') self.mapper = Mapper() self.resource_list_name = 'resourcelist.xml' self.change_list_name = 'changelist.xml' diff --git a/resync/client_utils.py b/resync/client_utils.py index 499c292..b5d14f2 100644 --- a/resync/client_utils.py +++ b/resync/client_utils.py @@ -57,7 +57,7 @@ def init_logging(to_file=False, logfile=None, default_logfile='/tmp/resync.log', fh.setFormatter(formatter) fh.setLevel( logging.DEBUG if (eval_mode) else logging.INFO ) - loggers = [default_logger,'resourcelist_builder','sitemap'] + loggers = [default_logger,'resync'] if (extra_loggers is not None): for logger in extra_loggers: loggers.append(logger) diff --git a/resync/dump.py b/resync/dump.py index ca98c1c..b9bdb68 100644 --- a/resync/dump.py +++ b/resync/dump.py @@ -18,8 +18,9 @@ class Dump(object): rl = ResourceList() # ... add items by whatever means, may have >50k items and/or # >100MB total size of files ... - d = Dump(rl) - d.write(dumpfile="/tmp/rd") + d = Dump() + d.write(resources=rl,basename="/tmp/rd_") + # will create dump files /tmp/rd_00001.zip etc. """ def __init__(self, resources=None, format=None, compress=True): @@ -30,7 +31,7 @@ class Dump(object): self.max_size = 100*1024*1024 #100MB self.max_files = 50000 self.path_prefix = None - self.logger = logging.getLogger('dump') + self.logger = logging.getLogger('resync.dump') def write(self, basename=None, write_separate_manifests=True): """Write one or more dump files to complete this dump diff --git a/resync/list_base.py b/resync/list_base.py index f81bf24..20d321f 100644 --- a/resync/list_base.py +++ b/resync/list_base.py @@ -41,7 +41,7 @@ class ListBase(ResourceContainer): self.sitemapindex = False self.pretty_xml = False # - self.logger = logging.getLogger('list_base') + self.logger = logging.getLogger('resync.list_base') self.bytes_read = 0 self.parsed_index = None diff --git a/resync/mapper.py b/resync/mapper.py index 6aa1516..303e698 100644 --- a/resync/mapper.py +++ b/resync/mapper.py @@ -11,7 +11,7 @@ class MapperError(Exception): class Mapper(): def __init__(self, mappings=None, use_default_path=False): - self.logger = logging.getLogger('mapper') + self.logger = logging.getLogger('resync.mapper') self.mappings=[] if (mappings): self.parse(mappings, use_default_path) @@ -39,7 +39,7 @@ class Mapper(): len(mappings)==1 and re.search(r"=",mappings[0])==None): path = self.path_from_uri(mappings[0]) - self.logger.info("Assuming mapping: %s -> %s" % (mappings[0],path)) + self.logger.warning("Using URI mapping: %s -> %s" % (mappings[0],path)) self.mappings.append(Map(mappings[0],path)) elif (len(mappings)==2 and re.search(r"=",mappings[0])==None and diff --git a/resync/resource_list_builder.py b/resync/resource_list_builder.py index 10a22d1..b424022 100644 --- a/resync/resource_list_builder.py +++ b/resync/resource_list_builder.py @@ -51,7 +51,7 @@ class ResourceListBuilder(): self.exclude_dirs = ['CVS','.git'] self.include_symlinks = False # Used internally only: - self.logger = logging.getLogger('resource_list_builder') + self.logger = logging.getLogger('resync.resource_list_builder') self.compiled_exclude_files = [] def add_exclude_files(self, exclude_patterns): diff --git a/resync/sitemap.py b/resync/sitemap.py index 6531191..1f2b183 100644 --- a/resync/sitemap.py +++ b/resync/sitemap.py @@ -56,7 +56,7 @@ class Sitemap(object): """ def __init__(self, pretty_xml=False): - self.logger = logging.getLogger('sitemap') + self.logger = logging.getLogger('resync.sitemap') self.pretty_xml=pretty_xml # Classes used when parsing self.resource_class=Resource