connectionmonitoring/connectionmonitorui/inc/ConnectionMonitorUiLogger.h
branchRCL_3
changeset 58 83ca720e2b9a
parent 0 5a93021fdf25
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
       
     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:  Logging support for R&D purposes
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CONNECTIONMONITORUILOGGER_H_INCLUDED
       
    21 #define CONNECTIONMONITORUILOGGER_H_INCLUDED
       
    22 
       
    23 // ========== INCLUDE FILES ================================
       
    24 
       
    25 #include <eikenv.h>
       
    26 #include <flogger.h>
       
    27 
       
    28 // ========== CONSTANTS ====================================
       
    29 
       
    30 #ifdef _DEBUG
       
    31 
       
    32 _LIT( KCMUILogDir,              "CMUI");
       
    33 _LIT( KCMUILogFile,             "CMUI.txt");
       
    34 _LIT(KCMUILogBanner,            "CMUI 0.1.0");
       
    35 _LIT(KCMUILogEnterFn,           "CMUI: -> %S");
       
    36 _LIT(KCMUILogLeaveFn,           "CMUI: <- %S");
       
    37 _LIT(KCMUILogExit,              "CMUI: Application exit");
       
    38 _LIT( KCMUILogTimeFormatString, "%H:%T:%S:%*C2");
       
    39 
       
    40 // ========== MACROS =======================================
       
    41 
       
    42 #define CMUILOGGER_CREATE             {FCreate();}
       
    43 #define CMUILOGGER_DELETE             {RFileLogger::Write(KCMUILogDir, KCMUILogFile, EFileLoggingModeAppend, KCMUILogExit);}
       
    44 #define CMUILOGGER_ENTERFN(a)         {_LIT(temp, a); RFileLogger::WriteFormat(KCMUILogDir, KCMUILogFile, EFileLoggingModeAppend, KCMUILogEnterFn, &temp);}
       
    45 #define CMUILOGGER_LEAVEFN(a)         {_LIT(temp, a); RFileLogger::WriteFormat(KCMUILogDir, KCMUILogFile, EFileLoggingModeAppend, KCMUILogLeaveFn, &temp);}
       
    46 #define CMUILOGGER_WRITE(a)           {_LIT(temp, a); RFileLogger::Write(KCMUILogDir, KCMUILogFile, EFileLoggingModeAppend, temp);}
       
    47 #define CMUILOGGER_WRITE_F(a, b)      {_LIT(temp, a); RFileLogger::WriteFormat(KCMUILogDir, KCMUILogFile, EFileLoggingModeAppend, temp, b);}
       
    48 #define CMUILOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KCMUILogTimeFormatString ); buffer.Insert(0, temp); RFileLogger::Write(KCMUILogDir, KCMUILogFile, EFileLoggingModeAppend, buffer); }
       
    49 #define CMUILOGGER_WRITEF             FPrint
       
    50 
       
    51 
       
    52 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
       
    53     {
       
    54     VA_LIST list;
       
    55     VA_START(list,aFmt);
       
    56     RFileLogger::WriteFormat(KCMUILogDir, KCMUILogFile, EFileLoggingModeAppend, aFmt, list);
       
    57     }
       
    58 
       
    59 inline void FPrint(const TDesC& aDes)
       
    60     {
       
    61     RFileLogger::WriteFormat(KCMUILogDir, KCMUILogFile, EFileLoggingModeAppend, aDes);
       
    62     }
       
    63 
       
    64 inline void FHex(const TUint8* aPtr, TInt aLen)
       
    65     {
       
    66     RFileLogger::HexDump(KCMUILogDir, KCMUILogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
       
    67     }
       
    68 
       
    69 inline void FHex(const TDesC8& aDes)
       
    70     {
       
    71     FHex(aDes.Ptr(), aDes.Length());
       
    72     }
       
    73 
       
    74 inline void FCreate()
       
    75     {
       
    76     TFileName path(_L("c:\\logs\\"));
       
    77     path.Append(KCMUILogDir);
       
    78     path.Append(_L("\\"));
       
    79     RFs& fs = CEikonEnv::Static()->FsSession();
       
    80     fs.MkDirAll(path);
       
    81     RFileLogger::WriteFormat(KCMUILogDir, KCMUILogFile, EFileLoggingModeOverwrite, KCMUILogBanner);
       
    82     }
       
    83 
       
    84 #else // ! _DEBUG
       
    85 
       
    86 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { };
       
    87 
       
    88 #define CMUILOGGER_CREATE
       
    89 #define CMUILOGGER_DELETE
       
    90 #define CMUILOGGER_ENTERFN(a)
       
    91 #define CMUILOGGER_LEAVEFN(a)
       
    92 #define CMUILOGGER_WRITE(a)
       
    93 #define CMUILOGGER_WRITE_F(a, b)
       
    94 #define CMUILOGGER_WRITEF   1 ? ((void)0) : FPrint
       
    95 #define CMUILOGGER_WRITE_TIMESTAMP(a)
       
    96 
       
    97 #endif // _DEBUG
       
    98 
       
    99 // ========== DATA TYPES ===================================
       
   100 
       
   101 // ========== FUNCTION PROTOTYPES ==========================
       
   102 
       
   103 // ========== FORWARD DECLARATIONS =========================
       
   104 
       
   105 // ========== CLASS DECLARATION ============================
       
   106 
       
   107 #endif // CONNECTIONMONITORUILOGGER_H_INCLUDED