Never log ignored warnings.

This commit is contained in:
Bastian Kleineidam 2012-09-20 12:44:40 +02:00
parent 600b7c0e69
commit bff217c58b
3 changed files with 8 additions and 11 deletions

View file

@ -21,6 +21,8 @@ Changes:
- logging: All sitemap loggers log all valid URLs regardless of the
--warnings or --complete options. This way the sitemaps can be
logged to file without changing the output of URLs in other loggers.
- logging: Ignored warnings are now never logged, even when the URL
has errors.
Fixes:
- logging: Close logger properly on I/O errors.

View file

@ -135,9 +135,6 @@ class UrlBase (object):
"""
self.base_ref = base_ref
self.base_url = base_url.strip() if base_url else base_url
if self.base_url != base_url:
self.add_warning(_("Leading or trailing whitespace in URL `%(url)s'.") %
{"url": base_url}, tag=WARN_URL_WHITESPACE)
self.parent_url = parent_url
self.recursion_level = recursion_level
self.aggregate = aggregate
@ -155,6 +152,9 @@ class UrlBase (object):
url = absolute_url(self.base_url, base_ref, parent_url)
# assume file link if no scheme is found
self.scheme = url.split(":", 1)[0] or "file"
if self.base_url != base_url:
self.add_warning(_("Leading or trailing whitespace in URL `%(url)s'.") %
{"url": base_url}, tag=WARN_URL_WHITESPACE)
def reset (self):
"""
@ -305,7 +305,8 @@ class UrlBase (object):
Add a warning string.
"""
item = (tag, s)
if item not in self.warnings:
if item not in self.warnings and \
tag not in self.aggregate.config["ignorewarnings"]:
self.warnings.append(item)
def add_info (self, s):

View file

@ -28,7 +28,6 @@ class Logger (object):
"""Initialize basic logging variables."""
self.loggers = [config['logger']]
self.loggers.extend(config['fileoutput'])
self.ignorewarnings = config["ignorewarnings"]
self.verbose = config["verbose"]
self.complete = config["complete"]
self.warnings = config["warnings"]
@ -60,12 +59,7 @@ class Logger (object):
return False
if self.verbose:
return True
has_warnings = False
for tag, dummy in url_data.warnings:
if tag not in self.ignorewarnings:
has_warnings = True
break
if self.warnings and has_warnings:
if self.warnings and url_data.warnings:
return True
return not url_data.valid