jigdo API

util/log.hh File Reference

Logfile / debugging output. More...

#include <config.h>
#include <debug.hh>
#include <nocopy.hh>
#include <string-utf.hh>

Go to the source code of this file.


Classes

class  Logger
 Usually created by the DEBUG_UNIT macro, with an instance name of "debug"
  • an object which can be called to output debugging info.
More...

Defines

#define DEBUG_UNIT(_name)
#define LOCAL_DEBUG_UNIT(_name)
#define LOCAL_DEBUG_UNIT_DECL
#define DEBUG_TO(_realobject)
#define LOCAL_DEBUG_TO(_realobject)
#define debug(...)   do { } while (false)

Variables

Logger msg
 The default debugging logger uses the unit name "general".

Detailed Description

Logfile / debugging output.

The (Debug)Logger class shouldn't be used directly, only via the macros. The following:

DEBUG_UNIT("unitname")

ensures that debug("format %1", arg) either prints the debug message (if DEBUG is 1), or does nothing at all (if DEBUG is 0). "Nothing at all" really means nothing, not even evaluating the argument expressions - at least if variable-argument preprocessor macros are supported.

IMPORTANT: The expressions passed to debug() must not have any side-effects if the program is to behave identically with DEBUG=0 and DEBUG=1.

The following:

undef debug namespace { Logger debug("unitname"); }

Is like DEBUG_UNIT, except that the calls to debug() are always compiled in, regardless of the setting of DEBUG. Don't forget the undef debug!

Use LOCAL_DEBUG_UNIT to define "debug" in the current scope/namespace.

With DEBUG_TO(FooBar::debug), you can use a non-local debug object (e.g. defined in a header somewhere; the macro will define a local "debug" reference to FooBar::debug. Making direct calls to FooBar::debug would fail if DEBUG=0. Again, there's also a LOCAL_DEBUG_TO, to be used e.g. inside a function.

A "LOCAL_DEBUG_UNIT_DECL;" line should be used inside class definitions to introduce a static debug object (or non-static dummy if DEBUG=0). In the corresponding .cc file, you will need to add the following: if DEBUG Logger MyClass::debug("myclass"); endif


Define Documentation

#define debug ( ...   )     do { } while (false)

Referenced by addNoProxy(), addProxy(), UrlMap::addServer(), Debug::assertFail(), CacheFile::CacheFile(), Download::cleanup(), Download::cont(), Job::CachedUrl::cont(), GUI::create(), ZobstreamBz::deflateReset(), UrlMap::dumpJigdoInfo(), PartUrlMapping::enumerate(), CacheFile::expire(), JobList::finalize(), JigdoDescVec::get(), GtkSingleUrl::GtkSingleUrl(), Job::MakeImageDl::imageInfo(), Download::init(), Gunzip::inject(), JigdoConfig::JigdoConfig(), Job::MakeImageDl::jigdoFinished(), Job::JigdoIO::JigdoIO(), Job::MakeImageDl::killAllChildren(), JigdoDesc::makeImage(), mkimage(), GtkMakeImage::on_pauseButton_clicked(), GtkSingleUrl::on_restartButton_clicked(), GtkMakeImage::on_restartButton_clicked(), GtkMakeImage::on_startButton_clicked(), GtkMakeImage::on_stopButton_clicked(), ZobstreamGz::open(), ZobstreamBz::open(), parseComment(), parseEndElem(), parseStartElem(), parseText(), Download::pause(), proxyGuess(), Zibstream::read(), JobList::registerTicks(), JigdoConfig::rescan(), Download::run(), Job::SingleUrl::run(), Job::CachedUrl::run(), JigdoDesc::seekFromEnd(), Progress::setAutoTick(), MessageBox::show_noAutoClose(), Job::SingleUrl::SingleUrl(), Progress::speed(), Download::stop(), GtkSingleUrl::stop(), JobList::unregisterTicks(), writeAll(), writeMerge(), Zobstream::writeZipped(), ZobstreamGz::zip2(), ZobstreamBz::zip2(), Download::~Download(), GtkMakeImage::~GtkMakeImage(), GtkSingleUrl::~GtkSingleUrl(), JigdoCache::~JigdoCache(), Job::JigdoIO::~JigdoIO(), MessageBox::~MessageBox(), and Job::SingleUrl::~SingleUrl().

#define DEBUG_TO ( _realobject   ) 

#define DEBUG_UNIT ( _name   ) 

#define LOCAL_DEBUG_TO ( _realobject   ) 

#define LOCAL_DEBUG_UNIT ( _name   ) 

#define LOCAL_DEBUG_UNIT_DECL


Variable Documentation

The default debugging logger uses the unit name "general".

If possible, you should define a static, per-compilation-unit logger with a more descriptive name and use that instead.

Referenced by ap(), as(), Job::MakeImageDl::childFailed(), cmdOptions(), compare(), curlCallback(), expect(), expectEnum(), JigdoDesc::listMissing(), main(), JigdoDesc::makeImage(), memData(), Rand::Rand(), Job::MakeImageDl::run(), test(), testBetween(), testCase(), testCase2(), testFork(), testImageInfo(), testLoop(), testMinimal(), testNoMD5(), testSimple(), and testUriJoin().


Generated on Tue Sep 23 14:27:42 2008 for jigdo by  doxygen 1.5.6