diff --git a/doc/changelog.txt b/doc/changelog.txt index b20ce49f..ae05c52d 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -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. diff --git a/linkcheck/checker/urlbase.py b/linkcheck/checker/urlbase.py index ee4518f4..e0770677 100644 --- a/linkcheck/checker/urlbase.py +++ b/linkcheck/checker/urlbase.py @@ -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): diff --git a/linkcheck/director/logger.py b/linkcheck/director/logger.py index 1313a259..2463495b 100644 --- a/linkcheck/director/logger.py +++ b/linkcheck/director/logger.py @@ -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