wlanutilities/wlanplugin/inc/wlanpluginlogger.h
branchRCL_3
changeset 24 63be7eb3fc78
parent 23 b852595f5cbe
child 25 f28ada11abbf
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
     1 /*
       
     2 * Copyright (c) 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: Functions and macros for debugging
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef WLANPLUGINLOGGER_H_INCLUDED
       
    21 #define WLANPLUGINLOGGER_H_INCLUDED
       
    22 
       
    23 // ========== INCLUDE FILES ================================
       
    24 
       
    25 #include <eikenv.h>
       
    26 #include <flogger.h>
       
    27 
       
    28 #ifdef _DEBUG
       
    29 
       
    30 // Format string: enter function.
       
    31 _LIT( KCCDLGLogEnterFn,           "-> %S" );
       
    32 // Format string: leave function.
       
    33 _LIT( KCCDLGLogLeaveFn,           "<- %S" );
       
    34 // Format string: time.
       
    35 _LIT( KCCDLGLogTimeFormatString,  "%H:%T:%S:%*C2" );
       
    36 
       
    37 // Logging directory.
       
    38 _LIT( KCCDLGLogDir,               "wlanplugin" );
       
    39 // Log file name.
       
    40 _LIT( KCCDLGLogFile,              "wlanplugin.txt" );
       
    41 _LIT( KCCDLGLogBanner,            "****************\n\nWlanPlugin\n\n****************" );
       
    42 _LIT( KCCDLGLogExit,              "WlanPlugin : Exit" );
       
    43 
       
    44 #define CLOG_CREATE             {FCreate();}
       
    45 #define CLOG_DELETE             {RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogExit);}
       
    46 #define CLOG_ENTERFN(a)         {_LIT(temp, a); RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogEnterFn, &temp);}
       
    47 #define CLOG_LEAVEFN(a)         {_LIT(temp, a); RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogLeaveFn, &temp);}
       
    48 #define CLOG_WRITE(a)           {_LIT(temp, a); RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, temp);}
       
    49 #define CLOG_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KCCDLGLogTimeFormatString ); buffer.Insert(0, temp); RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, buffer); }
       
    50 #define CLOG_WRITEF             FPrint
       
    51 
       
    52 
       
    53 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
       
    54     {
       
    55     VA_LIST list;
       
    56     VA_START(list,aFmt);
       
    57     RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, aFmt, list);
       
    58     }
       
    59 
       
    60 inline void FPrint(const TDesC& aDes)
       
    61     {
       
    62     RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, aDes);
       
    63     }
       
    64 
       
    65 inline void FHex(const TUint8* aPtr, TInt aLen)
       
    66     {
       
    67     RFileLogger::HexDump(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
       
    68     }
       
    69 
       
    70 inline void FHex(const TDesC8& aDes)
       
    71     {
       
    72     FHex(aDes.Ptr(), aDes.Length());
       
    73     }
       
    74 
       
    75 inline void FCreate()
       
    76     {
       
    77     TFileName path( _L( "c:\\logs\\" ) );
       
    78     path.Append( KCCDLGLogDir );
       
    79     path.Append( _L( "\\" ) );
       
    80     RFs& fs = CEikonEnv::Static()->FsSession();
       
    81     fs.MkDirAll( path );
       
    82     RFileLogger::WriteFormat( KCCDLGLogDir, KCCDLGLogFile, 
       
    83                               EFileLoggingModeAppend, KCCDLGLogBanner );
       
    84     }
       
    85 
       
    86 #else // ! _DEBUG
       
    87 
       
    88 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { };
       
    89 
       
    90 #define CLOG_CREATE
       
    91 #define CLOG_DELETE
       
    92 #define CLOG_ENTERFN(a)
       
    93 #define CLOG_LEAVEFN(a)
       
    94 #define CLOG_WRITE(a)
       
    95 #define CLOG_WRITEF   1 ? ((void)0) : FPrint
       
    96 #define CLOG_WRITE_TIMESTAMP(a)
       
    97 
       
    98 #endif // _DEBUG
       
    99 
       
   100 
       
   101 #endif // WLANPLUGINLOGGER_H_INCLUDED