codhandler/roapapp/inc/RoapAppLogger.h
changeset 0 dd21522fd290
child 26 cb62a4f66ebe
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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 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: 
       
    15 *      Logging macros.   
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef ROAP_APP_LOGGER_H
       
    22 #define ROAP_APP_LOGGER_H
       
    23 
       
    24 // INCLUDES
       
    25 
       
    26 #include <e32std.h>
       
    27 #include <e32def.h>
       
    28 #include <flogger.h>
       
    29 
       
    30 /**
       
    31 * Determines log detail.
       
    32 * - 0 -> Basic level. Only key events / data. Public API method calls.
       
    33 *        Failures (panics).
       
    34 * - 1 -> Basic level. More detailed about key events / data.
       
    35 * - 2 -> Medium level. Function calls are logged.
       
    36 * - 3 -> Medium level. More detailed. Observer callbacks.
       
    37 * - 4 -> Detailed level.
       
    38 * - 5 -> Detailed level. Most detailed, log grows very big.
       
    39 */
       
    40 #define ROAP_APP_LOG_LEVEL 4
       
    41 
       
    42 #ifdef _DEBUG
       
    43 
       
    44     /// Defining this enables logging. Needs flogger.lib.
       
    45     #define __TEST_ROAP_APP_LOG
       
    46 
       
    47 #endif /* def _DEBUG */
       
    48 
       
    49 #ifdef __TEST_ROAP_APP_LOG
       
    50 
       
    51     // CLASS DECLARATION
       
    52 
       
    53     /**
       
    54     * Logger class.
       
    55     */
       
    56     class RoapAppLogger
       
    57         {
       
    58         public:     // new methods
       
    59 
       
    60         /**
       
    61         * Write formatted log.
       
    62         * @param aLevel Log level.
       
    63         * @param aFmt Format string.
       
    64         */
       
    65         static void Write
       
    66             ( TInt aLevel, TRefByValue<const TDesC16> aFmt, ... );
       
    67 
       
    68         /**
       
    69         * Write formatted log.
       
    70         * @param aLevel Log level.
       
    71         * @param aFmt Format string.
       
    72         * @param aList Variable argument list.
       
    73         */
       
    74         static void Write
       
    75             (
       
    76             TInt aLevel,
       
    77             TRefByValue<const TDesC16> aFmt,
       
    78             VA_LIST& aList
       
    79             );
       
    80 
       
    81         /**
       
    82         * Write formatted log.
       
    83         * @param aLevel Log level.
       
    84         * @param aFmt Format string.
       
    85         */
       
    86         static void Write
       
    87             ( TInt aLevel, TRefByValue<const TDesC8> aFmt, ... );
       
    88 
       
    89         /**
       
    90         * Write formatted log.
       
    91         * @param aLevel Log level.
       
    92         * @param aFmt Format string.
       
    93         * @param aList Variable argument list.
       
    94         */
       
    95         static void Write
       
    96             (
       
    97             TInt aLevel,
       
    98             TRefByValue<const TDesC8> aFmt,
       
    99             VA_LIST& aList
       
   100             );
       
   101 
       
   102         /**
       
   103         * Write hex dump.
       
   104         * @param aLevel Log level.
       
   105         * @param aHeader Header string.
       
   106         * @param aMargin Margin.
       
   107         * @param aPtr Data.
       
   108         * @param aLen Data length.
       
   109         */
       
   110         static void HexDump
       
   111             (
       
   112             TInt aLevel, 
       
   113             const TText* aHeader,
       
   114             const TText* aMargin,
       
   115             const TUint8* aPtr,
       
   116             TInt aLen
       
   117             );
       
   118         };
       
   119 
       
   120 #endif /* def __TEST_ROAP_APP_LOG */
       
   121 
       
   122 #ifdef __TEST_ROAP_APP_LOG
       
   123 
       
   124     /// Write formatted to log.
       
   125     #define CLOG( body ) RoapAppLogger::Write body
       
   126     /// Write hex dump.
       
   127     #define CDUMP( body ) RoapAppLogger::HexDump body
       
   128     /// Guard "log-only" argument name with this (expands to argument).
       
   129     #define LOG_ONLY( argName ) argName
       
   130 
       
   131 #else /* not defined __TEST_ROAP_APP_LOG */
       
   132 
       
   133     /// Do nothing (log disabled).
       
   134     #define CLOG( body )
       
   135     /// Do nothing (log disabled).
       
   136     #define CDUMP( body )
       
   137     /// Guard "log-only" argument name with this (expands to nothing).
       
   138     #define LOG_ONLY( argName )
       
   139 
       
   140 #endif /* def __TEST_ROAP_APP_LOG */
       
   141 
       
   142 #ifdef _DEBUG
       
   143 
       
   144     /// Guard "debug-only" argument name with this (expands to argument).
       
   145     #define DEBUG_ONLY( argName ) argName
       
   146 
       
   147 #else /* not defined _DEBUG */
       
   148 
       
   149     /// Guard "ldebug-only" argument name with this (expands to nothing).
       
   150     #define DEBUG_ONLY( argName )
       
   151 
       
   152 #endif /* def _DEBUG */
       
   153 
       
   154 #endif /* def ROAP_APP_LOGGER_H */