Use hierarchical logger names

This commit is contained in:
Simeon Warner 2014-07-02 19:45:26 -04:00
parent 5a716c47ce
commit c62416fd11
8 changed files with 12 additions and 11 deletions

View File

@ -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" %

View File

@ -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'

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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