cbs/cbsui/inc/cbslog.h
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     1 /*
       
     2 * Copyright (c) 2010 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:  Offers logging facility through flogger
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CBSLOG_H
       
    20 #define CBSLOG_H
       
    21 
       
    22 // LOGGING LEVELS
       
    23 const TInt SIMPLE( 1 );
       
    24 const TInt NORMAL( 2 );
       
    25 const TInt DETAILED( 3 );
       
    26 
       
    27 #include <flogger.h>
       
    28 #include <e32svr.h> // For RDebug
       
    29 
       
    30 #define ENABLE_CBS_LOGGING
       
    31 
       
    32 
       
    33 #ifdef ENABLE_CBS_LOGGING
       
    34 
       
    35     //
       
    36     // DEFINE THE LOGGING LEVEL HERE: SIMPLE, NORMAL, DETAILED
       
    37     //
       
    38     #define LOGGING_LEVEL NORMAL
       
    39 
       
    40     // CONSTANTS
       
    41     _LIT( KLogDir, "cbs" );
       
    42     _LIT( KLogFile, "cbsui_qt.txt" );
       
    43 
       
    44     // This warning is disabled: conditinal expression is constant.
       
    45 
       
    46     //
       
    47     // USE THIS MACRO FOR LOGGING. THE LEVEL OF LOGGING CAN BE
       
    48     // SIMPLE, NORMAL, DETAILED
       
    49     //
       
    50     #ifdef LOG
       
    51         #undef LOG
       
    52     #endif
       
    53 
       
    54     #define LOG( LEVEL, TEXT ) \
       
    55         { \
       
    56         if ( LEVEL <= LOGGING_LEVEL ) \
       
    57             { \
       
    58             _LIT( KText, TEXT ); \
       
    59             RFileLogger::Write( \
       
    60                 KLogDir, \
       
    61                 KLogFile, \
       
    62                 EFileLoggingModeAppend, \
       
    63                 KText ); \
       
    64             RDebug::Print( KText ); \
       
    65             } \
       
    66         }
       
    67 
       
    68     #ifdef LOG2
       
    69         #undef LOG2
       
    70     #endif
       
    71 
       
    72     #define LOG2( LEVEL, TEXT, VARIABLE ) \
       
    73         { \
       
    74         if ( LEVEL <= LOGGING_LEVEL ) \
       
    75             { \
       
    76             _LIT( KText, TEXT ); \
       
    77             RFileLogger::WriteFormat( \
       
    78                 KLogDir, \
       
    79                 KLogFile, \
       
    80                 EFileLoggingModeAppend, \
       
    81                 TRefByValue<const TDesC>( KText() ), VARIABLE ); \
       
    82             RDebug::Print( KText, VARIABLE ); \
       
    83             } \
       
    84         }
       
    85 
       
    86     #ifdef LOG3
       
    87         #undef LOG3
       
    88     #endif
       
    89 
       
    90     #define LOG3( LEVEL, TEXT, VARIABLE1, VARIABLE2 ) \
       
    91         { \
       
    92         if ( LEVEL <= LOGGING_LEVEL ) \
       
    93             { \
       
    94             _LIT( KText, TEXT ); \
       
    95             RFileLogger::WriteFormat( \
       
    96                 KLogDir, \
       
    97                 KLogFile, \
       
    98                 EFileLoggingModeAppend, \
       
    99                 TRefByValue<const TDesC>( KText() ), VARIABLE1, VARIABLE2 ); \
       
   100             RDebug::Print( KText, VARIABLE1, VARIABLE2 ); \
       
   101             } \
       
   102         }
       
   103 
       
   104 #else // ENABLE_CBS_LOGGING
       
   105 
       
   106     #define LOG( LEVEL, TEXT )
       
   107 
       
   108     #define LOG2( LEVEL, TEXT, VARIABLE1 )
       
   109 
       
   110     #define LOG3( LEVEL, TEXT, VARIABLE1, VARIABLE2 )
       
   111 
       
   112 #endif // ENABLE_CBS_LOGGING
       
   113 
       
   114 #endif // CBSLOG_H