Home · All Namespaces · All Classes · Main Classes
Functions

McpDebug Namespace Reference

Functions

void time (const QString &msg="")
 Prints out a message with the current time.
void start (const QString &msg="")
 Marks the start of msg. Can be used with McpDebug::end to easily debug how long time it took between start and end.
void end (const QString &msg="")
 Marks the end of msg.
void mcpMsg (QtMsgType type, const char *msg)
 message handler for qDebug
void mcpPrintMsg (QtMsgType type, const char *function, const char *formatstring,...)

Function Documentation

void McpDebug::end ( const QString &  msg = ""  ) 

Marks the end of msg.

McpDebug::start marks the start, it can be used to easily debug how long time it took between start and end.

Definition at line 59 of file mcpdebug.cpp.

                                     {
    MCP_DEBUG ("");
    QTime last = starttimes.take(msg);
    time(msg + " ends, elapsed time: " + QString::number(
                last.msecsTo(QTime::currentTime())));
}

Here is the call graph for this function:

void McpDebug::mcpMsg ( QtMsgType  type,
const char *  msg 
)

message handler for qDebug

this function can be installed as a message handler for for debugging with Qt way, using qDebug()

Definition at line 72 of file mcpdebug.cpp.

{
    switch (type) {
        case QtDebugMsg:
            fprintf (stderr, "%s%s\n", DEBUG_PREFIX, msg);
            break;

        case QtWarningMsg:
            fprintf (stderr, "%s* %s *\n", DEBUG_PREFIX, msg);
            break;

        case QtCriticalMsg:
            fprintf (stderr, "%s** %s **\n", DEBUG_PREFIX, msg);
            break;

        case QtFatalMsg:
            fprintf (stderr, "Fatal: %s%s\n", DEBUG_PREFIX, msg);
            fflush (stderr);
            abort();
    }

    fflush (stderr);
}

void McpDebug::mcpPrintMsg ( QtMsgType  type,
const char *  function,
const char *  formatstring,
  ... 
)

Definition at line 105 of file mcpdebug.cpp.

{
    va_list args;

    va_start (args, formatstring);
    switch (type) {
        case QtDebugMsg:
            fprintf (stderr, "%s%s%s: ",
                    TERM_GREEN, function, TERM_NORMAL);
            vfprintf (stderr, formatstring, args);
            break;

        case QtWarningMsg:
            fprintf (stderr, "%s%s%s: ",
                    TERM_YELLOW, function, TERM_NORMAL);
            vfprintf (stderr, formatstring, args);
            break;

        case QtCriticalMsg:
            fprintf (stderr, "%s%s%s: ",
                    TERM_RED, function, TERM_NORMAL);
            vfprintf (stderr, formatstring, args);
            break;

        case QtFatalMsg:
            fprintf (stderr, "%s%s%s: ",
                    TERM_GREEN, function, TERM_NORMAL);
            vfprintf (stderr, formatstring, args);
            fprintf (stderr, "\n%s%s%s: Aborting program.",
                    TERM_RED TERM_BOLD, function, TERM_NORMAL);
            fputc('\n', stderr);
            fflush (stderr);
            abort();
    }
    va_end (args);

    fputc('\n', stderr);
    fflush (stderr);
}

void McpDebug::start ( const QString &  msg = ""  ) 

Marks the start of msg. Can be used with McpDebug::end to easily debug how long time it took between start and end.

Definition at line 53 of file mcpdebug.cpp.

                                       {
    MCP_DEBUG ("");
    starttimes.insert(msg, QTime::currentTime());
    time(msg + " begins");
}

Here is the call graph for this function:

void McpDebug::time ( const QString &  msg = ""  ) 

Prints out a message with the current time.

Definition at line 47 of file mcpdebug.cpp.

                                      {
    MCP_DEBUG ("");
    qDebug() << DEBUG_PREFIX 
        << QTime::currentTime().toString("mm:ss.zzz") << msg;
}


Copyright © 2009 Nokia Corporation Generated on Thu Nov 4 2010 18:21:33
Doxygen 1.7.1
DirectUI