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