From 7e06912bcad1eeb71d8f154dff21555a5ed865ca Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Mon, 14 Apr 2014 16:18:07 -0400 Subject: [PATCH] Minor text changes to log message limitation --- docs/contribute.rst | 16 ++++++++-------- docs/settings.rst | 14 +++++++------- pelican/contents.py | 2 +- pelican/log.py | 4 ++-- pelican/settings.py | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/contribute.rst b/docs/contribute.rst index 28df1fcd..57349156 100644 --- a/docs/contribute.rst +++ b/docs/contribute.rst @@ -157,24 +157,24 @@ For logging messages that are not repeated, use the usual Python way: logger = logging.getLogger(__name__) # when needed - logger.warning('A warning that could occur only once") + logger.warning("A warning that would usually occur only once") However, if you want to log messages that may occur several times, instead of -a string, gives a tuple to the logging method, with two arguments: +a string, give a tuple to the logging method, with two arguments: - 1. The message to log for this very execution - 2. A generic message that will appear if the previous one would occur to many + 1. The message to log for the initial execution + 2. A generic message that will appear if the previous one would occur too many times. For example, if you want to log missing resources, use the following code: - for ressource in ressources: - if ressource.is_missing: + for resource in resources: + if resource.is_missing: logger.warning(( - 'The resource {r} is missing'.format(r=ressource.name), + 'The resource {r} is missing'.format(r=resource.name), 'Other resources were missing')) -The logs will be displayed as follows: +The log messages will be displayed as follows: WARNING: The resource prettiest_cat.jpg is missing WARNING: The resource best_cat_ever.jpg is missing diff --git a/docs/settings.rst b/docs/settings.rst index c35bf08d..36cc3f9a 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -88,7 +88,7 @@ Setting name (default value) here or a single string representing one locale. When providing a list, all the locales will be tried until one works. -`LOG_FILTER` (``[]``) A list of tuples containing the logging level (up to warning) +`LOG_FILTER` (``[]``) A list of tuples containing the logging level (up to ``warning``) and the message to be ignored. For example: ``[(logging.WARN, 'TAG_SAVE_AS is set to False')]`` `READERS` (``{}``) A dictionary of file extensions / Reader classes for Pelican to @@ -701,15 +701,15 @@ adding the following to your configuration:: Logging ======= -Sometimes, useless lines of log appears while the generation occurs. Finding -**the** meaningful error message in the middle of tons of annoying log outputs -can be quite tricky. To be able to filter out all useless log messages, Pelican +Sometimes, a long list of warnings may appear during site generation. Finding +the **meaningful** error message in the middle of tons of annoying log output +can be quite tricky. In order to filter out redundant log messages, Pelican comes with the ``LOG_FILTER`` setting. ``LOG_FILTER`` should be a list of tuples ``(level, msg)``, each of them being -composed of the logging level (up to warning) and the message to be ignored. -Simply populate the list with the logs you want to hide and they will be -filtered out. +composed of the logging level (up to ``warning``) and the message to be ignored. +Simply populate the list with the log messages you want to hide, and they will +be filtered out. For example: ``[(logging.WARN, 'TAG_SAVE_AS is set to False')]`` diff --git a/pelican/contents.py b/pelican/contents.py index 3096a064..615a7fd8 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -241,7 +241,7 @@ class Content(object): else: logger.warning(("Unable to find {fn}, skipping url" " replacement".format(fn=value), - "Other ressources were not found" + "Other resources were not found" " and their urls not replaced")) elif what == 'category': origin = Category(path, self.settings).url diff --git a/pelican/log.py b/pelican/log.py index d3aae012..fdf41cb0 100644 --- a/pelican/log.py +++ b/pelican/log.py @@ -78,7 +78,7 @@ class LimitFilter(logging.Filter): group_count = defaultdict(int) def filter(self, record): - # don't limit levels over warnings + # don't limit log messages for anything above "warning" if record.levelno > logging.WARN: return record # extract group @@ -105,7 +105,7 @@ class LimitFilter(logging.Filter): class LimitLogger(logging.Logger): """ - A logger which add LimitFilter automatically + A logger which adds LimitFilter automatically """ limit_filter = LimitFilter() diff --git a/pelican/settings.py b/pelican/settings.py index f70f74a8..7277c121 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -171,15 +171,15 @@ def get_settings_from_file(path, default_settings=DEFAULT_CONFIG): def configure_settings(settings): - """Provide optimizations, error checking and warnings for the given + """Provide optimizations, error checking, and warnings for the given settings. - Set up the logs to be ignored as well. + Also, specify the log messages to be ignored. """ if not 'PATH' in settings or not os.path.isdir(settings['PATH']): raise Exception('You need to specify a path containing the content' ' (see pelican --help for more information)') - # set up logs to be ignored + # specify the log messages to be ignored LimitFilter.ignore.update(set(settings.get('LOG_FILTER', DEFAULT_CONFIG['LOG_FILTER'])))