From 2c5350709793dfb22230bf8056979b88a713b513 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Wed, 9 Mar 2011 12:08:03 +0100 Subject: [PATCH] Improved logging documentation. --- linkcheck/logger/__init__.py | 11 ++++++++++- linkcheck/logger/text.py | 25 ------------------------- linkcheck/logger/xmllog.py | 2 +- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/linkcheck/logger/__init__.py b/linkcheck/logger/__init__.py index 57a43f5b..18e29dc4 100644 --- a/linkcheck/logger/__init__.py +++ b/linkcheck/logger/__init__.py @@ -124,7 +124,7 @@ class Logger (object): Base class for logging of checked urls. It defines the public API (see below) and offers basic functionality for all loggers. - Each logger has to offer the following functions: + Each logger offers the following functions: * start_output() Initialize and start log output. Most loggers print a comment @@ -136,6 +136,15 @@ class Logger (object): Log a checked URL. The url_data object is a transport form of the UrlData class. The do_print flag indicates if this URL should be logged or just used to update internal statistics. + + Each subclassed logger must implement the following functions: + + * start_output() + Also call the base class implementation of this. + * end_output() + See above. + * log_url(url_data) + Log a checked URL. Called by log_filter_url if do_print is True. """ def __init__ (self, **args): diff --git a/linkcheck/logger/text.py b/linkcheck/logger/text.py index 46d1fafd..c508dee2 100644 --- a/linkcheck/logger/text.py +++ b/linkcheck/logger/text.py @@ -26,31 +26,6 @@ class TextLogger (Logger): """ A text logger, colorizing the output if possible. - Every Logger has to implement the following functions: - - C{def start_output (self)} - Called once to initialize the Logger. Why do we not use __init__(self)? - Because we initialize the start time in start_output and __init__ gets - not called at the time the checking starts but when the logger object is - created. - Another reason is that we might want to create several loggers - as a default and then switch to another configured output. So we - must not print anything out at __init__ time. - - C{def log_filter_url (self, url_data, do_print)} - Called every time an url finished checking. All data we checked is in - the UrlData object url_data. - - C{def end_output (self)} - Called at the end of checking to close filehandles and such. - - Passing parameters to the constructor: - - C{def __init__ (self, **args)} - The args dictionary is filled in Config.py. There you can specify - default parameters. Adjust these parameters in the configuration - files in the appropriate logger section. - Informal text output format spec: Output consists of a set of URL logs separated by one or more blank lines. diff --git a/linkcheck/logger/xmllog.py b/linkcheck/logger/xmllog.py index c5739722..fbec2200 100644 --- a/linkcheck/logger/xmllog.py +++ b/linkcheck/logger/xmllog.py @@ -45,7 +45,7 @@ def xmlquoteattr (s): class XMLLogger (Logger): - """XML output; easy to parse with any XML tool.""" + """Base class for XML output; easy to parse with any XML tool.""" def __init__ (self, **args): """