browserutilities/aiwbrowserprovider/inc/logger.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Implemented logger functionality of the module
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef LOGGER_H
       
    20 #define LOGGER_H
       
    21 
       
    22 #ifdef _DEBUG
       
    23 // INCLUDES
       
    24 
       
    25 #include <flogger.h>
       
    26 #include <eikenv.h>
       
    27 
       
    28 // log files are stored to KDebugLogDirFull folder
       
    29 _LIT(KDebugLogDependency,       "C:\\Logs\\");
       
    30 _LIT(KDebugLogDoubleBackSlash,  "\\");
       
    31 
       
    32 _LIT( KDebugLogDir,             "AiwBrowserProvider");
       
    33 _LIT( KDebugLogFile,            "AiwBrowserProvider.log");
       
    34 _LIT( KDebugLogTitle,           "- AiwBrowserProvider Debug Log File -");
       
    35 _LIT( KLogMessageAppBanner,     "AiwBrowserProvider: module (%d.%d.%d) started" );
       
    36 _LIT( KDebugLogEnterFn,         "AiwBrowserProvider: -> %S" );
       
    37 _LIT( KDebugLogLeaveFn,         "AiwBrowserProvider: <- %S" );
       
    38 _LIT( KDebugLogTimeFormatString,"%H:%T:%S:%*C3" );
       
    39 _LIT( KDebugLogExit,            "AiwBrowserProvider: module exit" );
       
    40 
       
    41 
       
    42 // MACROS
       
    43 
       
    44 /**
       
    45 * Use this macro in order to initialize logger :
       
    46 * - create log directory,
       
    47 * - write version information into the log file
       
    48 */
       
    49 #define LOG_CREATE { TFileName path( KDebugLogDependency ); path.Append( KDebugLogDir ); path.Append( KDebugLogDoubleBackSlash ); RFs& fs = CEikonEnv::Static()->FsSession(); fs.MkDirAll( path ); RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile, EFileLoggingModeOverwrite, KLogMessageAppBanner ); }
       
    50 
       
    51 /**
       
    52 * Use this macro for writing information about exiting.
       
    53 */
       
    54 #define LOG_DELETE { RFileLogger::Write( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, KDebugLogExit ); }
       
    55 
       
    56 /**
       
    57 * Use this function at any points of a function for logging the current state.
       
    58 * @param a String to be written into logfile about the current state
       
    59 */
       
    60 #define LOG_WRITE( a ) { _LIT( temp, a ); RFileLogger::Write( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, temp ); RDebug::Print(temp);}
       
    61 
       
    62 /**
       
    63 * Use this function at any points of a function for logging the current state.
       
    64 * You can use printf-like formats, but with only one parameter to be substituted..
       
    65 * @param a Format string,
       
    66 * @param b Parameter to be substituted.
       
    67 */
       
    68 #define LOG_WRITE_FORMAT( a, b ) { _LIT( temp, a ); RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, temp, b ); RDebug::Print( temp, b);}
       
    69 
       
    70 /**
       
    71 * Use this function at any points of a function for logging the current state.
       
    72 * @param a String to be written into logfile about the current state
       
    73 */
       
    74 #define LOG_WRITE_TDES( a ) { RFileLogger::Write( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, a ); RDebug::Print( a );}
       
    75 
       
    76 /**
       
    77 * Use this function at any points of a function for logging the current state.
       
    78 * The current date/time stamp is written besides the string you give.
       
    79 * @param a String to be written into logfile about the current state
       
    80 */
       
    81 #define LOG_WRITE_TIMESTAMP( a ) { _LIT( temp, a ); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KDebugLogTimeFormatString ); buffer.Insert( 0, temp ); RFileLogger::Write( KDebugLogDir, KDebugLogFile, EFileLoggingModeAppend, buffer); RDebug::Print( buffer );}
       
    82 
       
    83 #else // _DEBUG
       
    84 
       
    85 // Empty macros
       
    86 #define LOG_CREATE
       
    87 #define LOG_DELETE
       
    88 #define LOG_ENTERFN( a )
       
    89 #define LOG_LEAVEFN( a )
       
    90 #define LOG_WRITE( a )
       
    91 #define LOG_WRITE_FORMAT( a, b )
       
    92 #define LOG_WRITE_TIMESTAMP( a )
       
    93 #define LOG_WRITE_HEXDUMP( p, l )
       
    94 #define LOG_WRITE_TDES( a )
       
    95 #endif // _DEBUG
       
    96 
       
    97 #endif	// LOG_LOGGER_H
       
    98 
       
    99 // End of file