mobilemessaging/mmsui/settingsinc/MmsSettingsLogging.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  
       
    15 *     Logging macros for MmsSettings.dll
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // ========== LOGGING MACROS ===============================
       
    22 
       
    23 #ifndef __MMSSETTINGSLOGGING_H
       
    24 #define __MMSSETTINGSLOGGING_H
       
    25 
       
    26 #ifdef USE_LOGGER
       
    27 
       
    28 #include <e32std.h>
       
    29 #include <e32def.h>
       
    30 #include <flogger.h>
       
    31 
       
    32 #ifdef USE_RDEBUG
       
    33 
       
    34 _LIT(KMMSSETTINGSLogBanner,             "MMSSETTINGS");
       
    35 _LIT(KMMSSETTINGSLogEnterFn,            "MMSSETTINGS: >> %S");
       
    36 _LIT(KMMSSETTINGSLogLeaveFn,            "MMSSETTINGS: << %S");
       
    37 _LIT(KMMSSETTINGSLogWrite,              "MMSSETTINGS: %S");
       
    38 _LIT(KMMSSETTINGSLogTag,                "MMSSETTINGS: ");
       
    39 _LIT(KMMSSETTINGSLogExit,               "MMSSETTINGS: Application exit");
       
    40 _LIT(KMMSSETTINGSLogTimeFormatString,   "%H:%T:%S:%*C2");
       
    41 
       
    42 #define MMSSETTINGSLOGGER_CREATE(a)          {RDebug::Print(KMMSSETTINGSLogBanner);}
       
    43 #define MMSSETTINGSLOGGER_DELETE             {RDebug::Print(KMMSSETTINGSLogExit);}
       
    44 #define MMSSETTINGSLOGGER_ENTERFN(a)         {_LIT(temp, a); RDebug::Print(KMMSSETTINGSLogEnterFn, &temp);}
       
    45 #define MMSSETTINGSLOGGER_LEAVEFN(a)         {_LIT(temp, a); RDebug::Print(KMMSSETTINGSLogLeaveFn, &temp);}
       
    46 #define MMSSETTINGSLOGGER_WRITE(a)           {_LIT(temp, a); RDebug::Print(KMMSSETTINGSLogWrite, &temp);}
       
    47 #define MMSSETTINGSLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KMMSSETTINGSLogTimeFormatString ); buffer.Insert(0, temp); buffer.Insert(0, KMMSSETTINGSLogTag); RDebug::Print(buffer); }
       
    48 #define MMSSETTINGSLOGGER_WRITEF             RDebug::Print
       
    49 
       
    50 #else
       
    51 
       
    52 _LIT( KMMSSETTINGSLogDir,               "MMSUI");
       
    53 _LIT( KMMSSETTINGSLogFile,              "MMSSETTINGS.txt");
       
    54 _LIT8(KMMSSETTINGSLogBanner,            "MMSSETTINGS");
       
    55 _LIT8(KMMSSETTINGSLogEnterFn,           "MMSSETTINGS: >> %S");
       
    56 _LIT8(KMMSSETTINGSLogLeaveFn,           "MMSSETTINGS: << %S");
       
    57 _LIT8(KMMSSETTINGSLogExit,              "MMSSETTINGS: Application exit");
       
    58 _LIT( KMMSSETTINGSLogTimeFormatString,  "%H:%T:%S:%*C2");
       
    59 
       
    60 #define MMSSETTINGSLOGGER_CREATE(a)          {FCreate(a);}
       
    61 #define MMSSETTINGSLOGGER_DELETE             {RFileLogger::Write(KMMSSETTINGSLogDir, KMMSSETTINGSLogFile, EFileLoggingModeAppend, KMMSSETTINGSLogExit);}
       
    62 #define MMSSETTINGSLOGGER_ENTERFN(a)         {_LIT8(temp, a); RFileLogger::WriteFormat(KMMSSETTINGSLogDir, KMMSSETTINGSLogFile, EFileLoggingModeAppend, KMMSSETTINGSLogEnterFn, &temp);}
       
    63 #define MMSSETTINGSLOGGER_LEAVEFN(a)         {_LIT8(temp, a); RFileLogger::WriteFormat(KMMSSETTINGSLogDir, KMMSSETTINGSLogFile, EFileLoggingModeAppend, KMMSSETTINGSLogLeaveFn, &temp);}
       
    64 #define MMSSETTINGSLOGGER_WRITE(a)           {_LIT(temp, a); RFileLogger::Write(KMMSSETTINGSLogDir, KMMSSETTINGSLogFile, EFileLoggingModeAppend, temp);}
       
    65 #define MMSSETTINGSLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KMMSSETTINGSLogTimeFormatString ); buffer.Insert(0, temp); RFileLogger::Write(KMMSSETTINGSLogDir, KMMSSETTINGSLogFile, EFileLoggingModeAppend, buffer); }
       
    66 #define MMSSETTINGSLOGGER_WRITEF             FPrint
       
    67 
       
    68 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
       
    69     {
       
    70     VA_LIST list;
       
    71     VA_START(list,aFmt);
       
    72     RFileLogger::WriteFormat(KMMSSETTINGSLogDir, KMMSSETTINGSLogFile, EFileLoggingModeAppend, aFmt, list);
       
    73     }
       
    74 
       
    75 inline void FPrint(const TDesC& aDes)
       
    76     {
       
    77     RFileLogger::WriteFormat(KMMSSETTINGSLogDir, KMMSSETTINGSLogFile, EFileLoggingModeAppend, aDes);
       
    78     }
       
    79 
       
    80 inline void FHex(const TUint8* aPtr, TInt aLen)
       
    81     {
       
    82     RFileLogger::HexDump(KMMSSETTINGSLogDir, KMMSSETTINGSLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
       
    83     }
       
    84 
       
    85 inline void FHex(const TDesC8& aDes)
       
    86     {
       
    87     FHex(aDes.Ptr(), aDes.Length());
       
    88     }
       
    89 
       
    90 inline void FCreate(RFs& aFs)
       
    91     {
       
    92     TFileName path(_L("c:\\logs\\"));
       
    93     path.Append(KMMSSETTINGSLogDir);
       
    94     path.Append(_L("\\"));
       
    95     aFs.MkDirAll(path);
       
    96     RFileLogger::WriteFormat(KMMSSETTINGSLogDir, KMMSSETTINGSLogFile, EFileLoggingModeOverwrite, KMMSSETTINGSLogBanner);
       
    97     }
       
    98 
       
    99 #endif // USE_RDEBUG
       
   100 
       
   101 #else // USE_LOGGER
       
   102 
       
   103 // dummy inline FPrint for MMSSETTINGSLOGGER_WRITEF macro.
       
   104 inline TInt FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { return 0; }
       
   105 
       
   106 #define MMSSETTINGSLOGGER_CREATE(a)
       
   107 #define MMSSETTINGSLOGGER_DELETE
       
   108 #define MMSSETTINGSLOGGER_ENTERFN(a)
       
   109 #define MMSSETTINGSLOGGER_LEAVEFN(a)
       
   110 #define MMSSETTINGSLOGGER_WRITE(a)
       
   111 // if USE_LOGGER not defined this call to FPrint gets optimized away.
       
   112 #define MMSSETTINGSLOGGER_WRITEF 1 ? 0 : FPrint
       
   113 #define MMSSETTINGSLOGGER_WRITE_TIMESTAMP(a)
       
   114 
       
   115 #endif // USE_LOGGER
       
   116 
       
   117 #endif // __MMSSETTINGSLOGGING_H
       
   118 
       
   119 // =========================================================