• Main Page
  • Classes
  • Files
  • File List

/home/bifh8/cs2009q3-i386/work/meegotouch-controlpanelapplets-0.20.61/src/debug.h

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (directui@nokia.com)
00006 **
00007 ** This file is part of meegotouch-controlpanelapplets.
00008 **
00009 ** If you have questions regarding the use of this file, please contact
00010 ** Nokia at directui@nokia.com.
00011 **
00012 ** This library is free software; you can redistribute it and/or
00013 ** modify it under the terms of the GNU Lesser General Public
00014 ** License version 2.1 as published by the Free Software Foundation
00015 ** and appearing in the file LICENSE.LGPL included in the packaging
00016 ** of this file.
00017 **
00018 ****************************************************************************/
00019 
00020 /******************************************************************************
00021  * The first part of the header can be loaded and loaded again, so we can turn
00022  * on and off the debug facility for each source file.
00023  */
00024 
00025 /*
00026  * Unfortunately testrunner.py sometimes drops an exception because the debug
00027  * messages are not UTF-8 strings. This is most probably because I have some
00028  * filenames printed in the functional tests. Could not find one though, so I
00029  * disabled the messages here.
00030  */
00031 //#ifdef UNIT_TEST
00032 //#  undef DEBUG
00033 //#endif
00034 #define DEBUG_TO_FILE
00035 
00036 #if defined(__ARMEL__) && !defined(DEBUG_TO_FILE)
00037 //#if !defined(DEBUG_TO_FILE)
00038 #  define DEBUG_TO_FILE
00039 #  ifndef DEBUG_SUPPRESS_COLOR
00040 #    define DEBUG_SUPPRESS_COLOR
00041 #  endif
00042 #endif
00043 
00044 /*
00045  * In production releases, we have to disable all the debug messages
00046  */
00047 #ifdef PUBLIC_RELEASE
00048 #   undef DEBUG
00049 #   undef WARNING
00050 #endif
00051 
00052 /*
00053  * If the debug facility is enabled we also enable all the warning messages.
00054  */
00055 #if defined(DEBUG) && !defined(WARNING)
00056 #  define WARNING
00057 #endif
00058 
00059 #if defined(WARNING) && !defined(CRITICAL)
00060 #  define CRITICAL
00061 #endif
00062 /*
00063  * The SYS_DEBUG macro is used to print normal debug messages.
00064  */
00065 #undef SYS_DEBUG
00066 #ifdef DEBUG
00067 #  define SYS_DEBUG(...) SysDebug::sysPrintMsg (\
00068         QtDebugMsg, \
00069         __PRETTY_FUNCTION__, \
00070         __VA_ARGS__)
00071 #else
00072 #  define SYS_DEBUG(...) { /* Nothing... */ }
00073 #endif
00074 
00075 /*
00076  * The SYS_WARNING is used to print warning messages.
00077  */
00078 #undef SYS_WARNING
00079 #ifdef WARNING
00080 #  define SYS_WARNING(...) SysDebug::sysPrintMsg (\
00081         QtWarningMsg, \
00082         __PRETTY_FUNCTION__, \
00083         __VA_ARGS__)
00084 #else
00085 #  define SYS_WARNING(...) { /* Nothing... */ }
00086 #endif
00087 
00088 /*
00089  * The SYS_CRITICAL is used to print warning messages.
00090  */
00091 #undef SYS_CRITICAL
00092 #ifdef CRITICAL
00093 #  define SYS_CRITICAL(...) SysDebug::sysPrintMsg (\
00094         QtCriticalMsg, \
00095         __PRETTY_FUNCTION__, \
00096         __VA_ARGS__)
00097 #else
00098 #  define SYS_CRITICAL(...) { /* Nothing... */ }
00099 #endif
00100 
00101 /******************************************************************************
00102  * Here we have those parts that can be loaded only once, so we protect them
00103  * with DEBUG_H. 
00104  */
00105 #ifndef DEBUG_H
00106 #define DEBUG_H
00107 
00108 #include <QTime>
00109 #include <QtDebug>
00110 
00111 #ifdef DEBUG_SUPPRESS_COLOR
00112 #  define TERM_RED     ""
00113 #  define TERM_YELLOW  ""
00114 #  define TERM_GREEN   ""
00115 #  define TERM_NORMAL  ""
00116 #  define TERM_BOLD    ""
00117 #else 
00118 #  define TERM_YELLOW  "\033[1;31m" 
00119 #  define TERM_RED     "\033[1;33m" 
00120 #  define TERM_GREEN   "\033[1;32m"
00121 #  define TERM_NORMAL  "\033[0;39m"
00122 #  define TERM_BOLD    "\033[1m"
00123 #endif
00124 
00125 namespace SysDebug
00126 {
00127     void sysPrintMsg (
00128         QtMsgType     type,
00129         const char   *function,
00130         const char   *formatstring,
00131         ...);
00132 };
00133 
00134 #define SYS_STR(qstring) (TERM_BOLD+qstring+TERM_NORMAL).toLatin1().constData()
00135 #define SYS_BOOL(boolean) (boolean ? \
00136         TERM_BOLD "true" TERM_NORMAL : \
00137         TERM_BOLD "false" TERM_NORMAL)
00138 
00139 #define SYS_TIME_STR SYS_STR(QTime::currentTime ().toString ("hh:mm:ss.zzz"))
00140 
00141 #endif

Generated on Mon Jul 11 2011 12:00:31 for libMeegoControl by  doxygen 1.7.1