wlansecuritysettings/wifiprotectedsetup/inc/wifiprotlogger.h
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2009 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 the License "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: Definition of macros used for logging 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef WIFIPROTLOGGER_H_INCLUDED
       
    20 #define WIFIPROTLOGGER_H_INCLUDED
       
    21 
       
    22 // ========== INCLUDE FILES ================================
       
    23 
       
    24 #include <eikenv.h>
       
    25 #include <flogger.h>
       
    26 
       
    27 #ifdef _DEBUG
       
    28 
       
    29 // Format string: enter function.
       
    30 _LIT( KCCDLGLogEnterFn,           "-> %S" );
       
    31 // Format string: leave function.
       
    32 _LIT( KCCDLGLogLeaveFn,           "<- %S" );
       
    33 // Format string: time.
       
    34 _LIT( KCCDLGLogTimeFormatString,  "%H:%T:%S:%*C2" );
       
    35 
       
    36 // Logging directory.
       
    37 _LIT( KCCDLGLogDir,               "wps" );
       
    38 // Log file name.
       
    39 _LIT( KCCDLGLogFile,              "wps.txt" );
       
    40 _LIT( KCCDLGLogBanner,            "****************\n\nWiFiProtectedSetupUi\n\n****************" );
       
    41 _LIT( KCCDLGLogExit,              "WiFiProtectedSetupUi: Exit" );
       
    42 
       
    43 #define CLOG_CREATE             {FCreate();}
       
    44 #define CLOG_DELETE             {RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogExit);}
       
    45 #define CLOG_ENTERFN(a)         {_LIT(temp, a); RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogEnterFn, &temp);}
       
    46 #define CLOG_LEAVEFN(a)         {_LIT(temp, a); RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogLeaveFn, &temp);}
       
    47 #define CLOG_WRITE(a)           {_LIT(temp, a); RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, temp);}
       
    48 #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); }
       
    49 #define CLOG_WRITEF             FPrint
       
    50 
       
    51 // ---------------------------------------------------------
       
    52 // FPrint
       
    53 // ---------------------------------------------------------
       
    54 //
       
    55 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
       
    56     {
       
    57     VA_LIST list;
       
    58     VA_START(list,aFmt);
       
    59     RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, aFmt, list);
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // FPrint
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 inline void FPrint(const TDesC& aDes)
       
    67     {
       
    68     RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, aDes);
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // FHex
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 inline void FHex(const TUint8* aPtr, TInt aLen)
       
    76     {
       
    77     RFileLogger::HexDump(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // FHex
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 inline void FHex(const TDesC8& aDes)
       
    85     {
       
    86     FHex(aDes.Ptr(), aDes.Length());
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // FCreate
       
    91 // ---------------------------------------------------------
       
    92 //
       
    93 inline void FCreate()
       
    94     {
       
    95     TFileName path( _L( "c:\\logs\\" ) );
       
    96     path.Append( KCCDLGLogDir );
       
    97     path.Append( _L( "\\" ) );
       
    98     RFs& fs = CEikonEnv::Static()->FsSession();
       
    99     fs.MkDirAll( path );
       
   100     RFileLogger::WriteFormat( KCCDLGLogDir, KCCDLGLogFile, 
       
   101                               EFileLoggingModeAppend, KCCDLGLogBanner );
       
   102     }
       
   103 
       
   104 #else // ! _DEBUG
       
   105 
       
   106 // ---------------------------------------------------------
       
   107 // FPrint
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { };
       
   111 
       
   112 #define CLOG_CREATE
       
   113 #define CLOG_DELETE
       
   114 #define CLOG_ENTERFN(a)
       
   115 #define CLOG_LEAVEFN(a)
       
   116 #define CLOG_WRITE(a)
       
   117 #define CLOG_WRITEF   1 ? ((void)0) : FPrint
       
   118 #define CLOG_WRITE_TIMESTAMP(a)
       
   119 
       
   120 #endif // _DEBUG
       
   121 
       
   122 
       
   123 #endif // WIFIPROTLOGGER_H_INCLUDED