X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fdebug.cpp;fp=src%2Fbase%2Fdebug.cpp;h=0000000000000000000000000000000000000000;hb=9f6ad3fe0b9cb30115a5d38e8af3aebed0d70c08;hp=36cb5ef054306182422d9ed4af07e26f8362497a;hpb=43c13b052d069ba435277d93867380d00c04931f;p=architektonas diff --git a/src/base/debug.cpp b/src/base/debug.cpp deleted file mode 100644 index 36cb5ef..0000000 --- a/src/base/debug.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// debug.cpp -// -// Part of the Architektonas Project -// Originally part of QCad Community Edition by Andrew Mustun -// Extensively rewritten and refactored by James L. Hammons -// Portions copyright (C) 2001-2003 RibbonSoft -// Copyright (C) 2010 Underground Software -// See the README and GPLv2 files for licensing and warranty information -// -// JLH = James L. Hammons -// -// Who When What -// --- ---------- ----------------------------------------------------------- -// JLH 05/28/2010 Added this text. :-) -// - -#include "debug.h" - -#include -#include "system.h" - -Debug * Debug::uniqueInstance = NULL; - -/** - * Gets the one and only Debug instance (creates a new one on first call only) - * - * @return Pointer to the single instance of this singleton class - */ -Debug * Debug::instance() -{ - if (uniqueInstance == NULL) - { - QDateTime now = QDateTime::currentDateTime(); - QString nowStr; - nowStr = now.toString("yyyyMMdd_hhmmss"); - QString fName = QString("debug_%1.log").arg(nowStr); - - uniqueInstance = new Debug; -// uniqueInstance->stream = fopen(fName.toAscii().data(), "wt"); -// uniqueInstance->stream = stderr; - uniqueInstance->stream = stdout; - } - - return uniqueInstance; -} - -/** - * Deletes the one and only Debug instance. - */ -void Debug::deleteInstance() -{ - if (uniqueInstance) - { - fclose(uniqueInstance->stream); - delete uniqueInstance; - } -} - -/** - * Constructor for a point with default coordinates. - */ -Debug::Debug() -{ - debugLevel = D_DEBUGGING; -} - -/** - * Sets the debugging level. - */ -void Debug::setLevel(DebugLevel level) -{ - debugLevel = level; - print("DEBUG: Warnings", D_WARNING); - print("DEBUG: Errors", D_ERROR); - print("DEBUG: Notice", D_NOTICE); - print("DEBUG: Informational", D_INFORMATIONAL); - print("DEBUG: Debugging", D_DEBUGGING); -} - -/** - * Gets the current debugging level. - */ -Debug::DebugLevel Debug::getLevel() -{ - return debugLevel; -} - -/** - * Prints the given message to stdout. - */ -void Debug::print(const char * format ...) -{ - if (debugLevel == D_DEBUGGING) - { - va_list ap; - va_start(ap, format); - vfprintf(stream, format, ap); - fprintf(stream, "\n"); - va_end(ap); - fflush(stream); - } -} - -/** - * Prints the given message to stdout if the current debug level - * is lower then the given level - * - * @param level Debug level. - */ -void Debug::print(DebugLevel level, const char * format ...) -{ - if (debugLevel >= level) - { - va_list ap; - va_start(ap, format); - vfprintf(stream, format, ap); - fprintf(stream, "\n"); - va_end(ap); - fflush(stream); - } -} - -/** - * Prints a time stamp in the format yyyyMMdd_hhmmss. - */ -void Debug::timestamp() -{ - QDateTime now = QDateTime::currentDateTime(); - QString nowStr = now.toString("yyyyMMdd_hh:mm:ss:zzz "); - fprintf(stream, "%s", nowStr.toAscii().data()); - fprintf(stream, "\n"); - fflush(stream); -} - -/** - * Prints the unicode for every character in the given string. - */ -void Debug::printUnicode(const QString & text) -{ - for(int i=0; i<(int)text.length(); i++) - print("[%X] %c", text.at(i).unicode(), text.at(i).toAscii()); -} - -void Debug::setStream(FILE * s) -{ - stream = s; -}