homesync/group/msdebug.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Common trace-information file.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DEBUG_H
       
    20 #define DEBUG_H
       
    21 
       
    22 /**
       
    23  *  NOTE: Link to flogger.lib in MMP file. Use DEBUGLIBRARY -keyword to avoid
       
    24  *        warnings in release builds.
       
    25  *        Example:  DEBUGLIBRARY    flogger.lib
       
    26  */
       
    27 
       
    28 /**
       
    29  * Usage: LOG(_L("[MODULE_NAME]\t Trace text here"));
       
    30  *        TRACE(Print(_L("[MODULE_NAME]\t Trace text here with parameter %d"),
       
    31  *              iCount));
       
    32  *
       
    33  *        Trace target can be changed below (file logging needs directory 
       
    34  *        c:\logs\upnp)
       
    35  *        #define __FLOGGING -row uncommented (default)  = File logging
       
    36  *        #define __CLOGGING -row uncommented            = Console logging
       
    37  */
       
    38 
       
    39 // undefine for sure
       
    40 #undef __FLOGGING__
       
    41 #undef __CLOGGING__
       
    42 
       
    43 #ifdef _DEBUG
       
    44 // Define one of these flags:
       
    45 // FLOGGING = File logging
       
    46 // CLOGGING = Console logging
       
    47 #define __FLOGGING__
       
    48 //#define __CLOGGING__
       
    49 #endif
       
    50 
       
    51 
       
    52 
       
    53 // Then actual definitions depending on the 
       
    54 // flag values.
       
    55 
       
    56 #ifdef _DEBUG
       
    57 
       
    58     #include <e32std.h>
       
    59 
       
    60 
       
    61     // Actual log file name
       
    62     _LIT(KLogFile,"ComponentLog.txt");
       
    63 
       
    64     // Subdirectory under c:\logs -directory
       
    65     _LIT(KLogDir, "component");
       
    66 
       
    67     #include <f32file.h>
       
    68     #include <flogger.h>
       
    69 
       
    70 
       
    71     // Define the top level macros
       
    72     #define LOG(a) {Print(a);}
       
    73     #define TRACE(a) {a;}
       
    74 
       
    75 
       
    76     #ifdef __FLOGGING__
       
    77 
       
    78         inline void Print(const TRefByValue<const TDesC> aFmt, ...)
       
    79             {
       
    80             VA_LIST list;
       
    81             VA_START(list,aFmt);
       
    82             TBuf<32> logFile(KLogFile);
       
    83             RFileLogger::WriteFormat( KLogDir, 
       
    84                                       logFile, 
       
    85                                       EFileLoggingModeAppend, 
       
    86                                       aFmt, 
       
    87                                       list );
       
    88             }
       
    89 
       
    90     #else
       
    91         // Console Logging on
       
    92         #define Print RDebug::Print
       
    93 
       
    94     #endif  // __FLOGGING__
       
    95 
       
    96 #else
       
    97 
       
    98     // DEBUG build is not on --> no logging at all
       
    99     #define LOG(a)
       
   100     #define TRACE(a)
       
   101 
       
   102 #endif  // _DEBUG
       
   103 
       
   104 #endif      // DEBUG_H
       
   105             
       
   106 // End of File