new trace option

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2601 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2005-05-17 22:06:47 +00:00
parent 50c536c82a
commit c0d9e56a4d
3 changed files with 12 additions and 1 deletions

View file

@ -335,6 +335,8 @@ class UrlBase (object):
"""
Main check function for checking this URL.
"""
if self.consumer.config["trace"]:
linkcheck.log.trace()
try:
self.local_check()
self.consumer.checked(self)

View file

@ -73,6 +73,8 @@ class Configuration (dict):
Initialize the default options.
"""
super(Configuration, self).__init__()
self['debug'] = False
self['trace'] = False
self["verbose"] = False
self["warnings"] = True
self['quiet'] = False
@ -173,7 +175,7 @@ class Configuration (dict):
handler = linkcheck.ansicolor.ColoredStreamHandler(strm=sys.stderr)
handler.setFormatter(logging.Formatter("%(levelname)s %(message)s"))
logging.getLogger(linkcheck.LOG).addHandler(handler)
if debug is not None:
if debug:
self['debug'] = True
# disable threading if no thread debugging
if "thread" not in debug:

View file

@ -390,6 +390,8 @@ than one logger.
For accurate results, threading and the psyco optimization module will
be disabled during debug runs.""") % \
{"lognamelist": linkcheck.lognamelist})
group.add_option("--trace", action="store_true", dest="trace",
help=_("""Print tracing information."""))
group.add_option("--profile", action="store_true", dest="profile",
help=_(
"""Write profiling data into a file named %s in the
@ -480,6 +482,9 @@ if options.debug:
# disable psyco if debugging is enabled to prevent that stack lists
# have PsycoFrame objects instead of types.FrameType
options.psyco = False
if options.trace:
# disable psyco for tracing
options.psyco = False
config.init_logging(debug=options.debug)
linkcheck.log.debug(linkcheck.LOG_CMDLINE, "Python %s on %s",
@ -641,6 +646,8 @@ if len(args) <= 0:
# initialize the cache and the consumer model
cache = linkcheck.checker.cache.Cache()
consumer = linkcheck.checker.consumer.Consumer(config, cache)
if options.trace:
linkcheck.log.trace()
# syntactic sugar
for url in args:
if url.lower().startswith("www."):