hti/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/HtiBtEngineLogging.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 0 a03f92240627
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     1 /*
       
     2 * Copyright (c) 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 "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 for Bluetooth engine.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __HTIBTENGINELOGGING_H__
       
    20 #define __HTIBTENGINELOGGING_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <flogger.h>
       
    24 
       
    25 /******************************************************/
       
    26 /**     LOG SETUP                                    **/
       
    27 /******************************************************/
       
    28 _LIT(KLogFolder, "Hti");
       
    29 _LIT(KLogFile, "BtSerialEngine.log");
       
    30 
       
    31 #ifdef __ENABLE_LOGGING__
       
    32 // Comment out the levels which are marked supported in the build
       
    33 // (and which are used runtime).
       
    34 //
       
    35 #define LOG_LEVEL_ERROR_SUPPORTED
       
    36 #define LOG_LEVEL_WARN_SUPPORTED
       
    37 #define LOG_LEVEL_INFO_SUPPORTED
       
    38 //#define LOG_LEVEL_DEBUG_SUPPORTED
       
    39 #endif
       
    40 
       
    41 /******************************************************/
       
    42 /**     MACRO DEFINITIONS                            **/
       
    43 /******************************************************/
       
    44 
       
    45 // Macros:                            Example:                                 Result:
       
    46 // LOGFMT_E(formatstring, parameter)  LOGFMT_E("Leave in RunL: %d", -6)        <TIME> ERROR: Leave in RunL: -6
       
    47 // LOG_E(string)                      LOG_E("There was an error")              <TIME> ERROR: There was an error
       
    48 // LOGFMT_W(formatstring, parameter)  LOGFMT_W("Buffer too small: %d", 12)     <TIME> WARNING: Buffer too small: 12
       
    49 // LOG_W(string)                      LOG_W("warmingtext")                     <TIME> WARNING: warningtext
       
    50 // LOGFMT_I(formatstring, parameter)  LOGFMT_I("plugin loaded: %S", &myDescr8) <TIME> INFO: plugin loaded: myplugin
       
    51 // LOG_I(string)                      LOG_I("abc")                             <TIME> INFO: abc
       
    52 // LOGFMT_D(formatstring, parameter)  LOGFMT_D("buffer length: %d", 56)        <TIME> DEBUG: buffer length: 56
       
    53 // LOG_D(string)                      LOG_D("abc")                             <TIME> DEBUG: abc
       
    54 
       
    55 #define ERRORSTR "ERROR: "
       
    56 #define WARNSTR  "WARNING: "
       
    57 #define INFOSTR  "INFO: "
       
    58 #define DEBUGSTR "DEBUG: "
       
    59 
       
    60 #ifdef LOG_LEVEL_ERROR_SUPPORTED
       
    61     #define LOGFMT_E(a1, a2) {_LIT8(temp, ERRORSTR##a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, a2);}
       
    62     #define LOG_E(a1) {_LIT8(temp, ERRORSTR##a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
       
    63 #else
       
    64     #define LOGFMT_E(a1, a2) {}
       
    65     #define LOG_E(a1) {}
       
    66 #endif
       
    67 
       
    68 #ifdef LOG_LEVEL_WARN_SUPPORTED
       
    69     #define LOGFMT_W(a1, a2) {_LIT8(temp, WARNSTR##a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, a2);}
       
    70     #define LOG_W(a1) {_LIT8(temp, WARNSTR##a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
       
    71 #else
       
    72     #define LOGFMT_W(a1, a2) {}
       
    73     #define LOG_W(a1) {}
       
    74 #endif
       
    75 
       
    76 #ifdef LOG_LEVEL_INFO_SUPPORTED
       
    77     #define LOGFMT_I(a1, a2) {_LIT8(temp, INFOSTR##a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, a2);}
       
    78     #define LOG_I(a1) {_LIT8(temp, INFOSTR##a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
       
    79 #else
       
    80     #define LOGFMT_I(a1, a2) {}
       
    81     #define LOG_I(a1) {}
       
    82 #endif
       
    83 
       
    84 #ifdef LOG_LEVEL_DEBUG_SUPPORTED
       
    85     #define LOGFMT_D(a1, a2) {_LIT8(temp, DEBUGSTR##a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, a2);}
       
    86     #define LOG_D(a1) {_LIT8(temp, DEBUGSTR##a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);}
       
    87 #else
       
    88     #define LOGFMT_D(a1, a2) {}
       
    89     #define LOG_D(a1) {}
       
    90 #endif
       
    91 
       
    92 #endif // __HTIBTENGINELOGGING_H__