webengine/widgetregistry/Server/inc/WidgetRegistryLog.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Log macro layer over flogger.h
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef WIDGETREGISTRYLOG_H
       
    21 #define WIDGETREGISTRYLOG_H
       
    22 
       
    23 #ifdef _DEBUG
       
    24 
       
    25 #include <bautils.h>
       
    26 #include <eikenv.h>
       
    27 #include <flogger.h>
       
    28 
       
    29 // add to class decl
       
    30 
       
    31 #define LOG_MEMBER_VARS \
       
    32  RFileLogger iLog; TInt iLogOpenCount; TFileLoggingMode iLogMode;
       
    33 
       
    34 // use remainder in impl
       
    35 
       
    36 #define LOG_NAMES( cstr_log_dir, cstr_log_file ) \
       
    37  _LIT( KLogDir, cstr_log_dir ); \
       
    38  _LIT( KLogFile, cstr_log_file );
       
    39 
       
    40 #define LOG_CONSTRUCTL \
       
    41  iLogOpenCount = 0; \
       
    42  User::LeaveIfError( iLog.Connect() ); \
       
    43  iLog.CreateLog( KLogDir, KLogFile, EFileLoggingModeOverwrite )
       
    44 
       
    45 #define LOG_DESTRUCT \
       
    46   if ( iLogOpenCount ) iLog.CloseLog(); \
       
    47   iLog.Close();
       
    48 
       
    49 #define LOG_OPEN \
       
    50  if ( !iLogOpenCount++ ) \
       
    51   iLog.CreateLog( KLogDir, KLogFile, EFileLoggingModeAppend )
       
    52 
       
    53 #define LOG_CLOSE \
       
    54  if ( iLogOpenCount && !(--iLogOpenCount) ) iLog.CloseLog()
       
    55 
       
    56 #define LOG_FLUSH \
       
    57  do { \
       
    58   if ( iLogOpenCount ) { \
       
    59    iLog.CloseLog(); \
       
    60    iLog.CreateLog( KLogDir, KLogFile, EFileLoggingModeAppend ); \
       
    61   } \
       
    62  } while ( 0 )
       
    63 
       
    64 #define LOG( cstr ) \
       
    65  iLog.Write( _L(cstr) )
       
    66 
       
    67 #define LOG_DES( des ) \
       
    68  iLog.Write( des )
       
    69 
       
    70 #define LOG1( cstr_fmt, arg1 ) \
       
    71  iLog.WriteFormat( _L(cstr_fmt), arg1 )
       
    72 
       
    73 #define LOG2( cstr_fmt, arg1, arg2 ) \
       
    74  iLog.WriteFormat( _L(cstr_fmt), arg1, arg2 )
       
    75 
       
    76 #define LOG3( cstr_fmt, arg1, arg2, arg3 ) \
       
    77  iLog.WriteFormat( _L(cstr_fmt), arg1, arg2, arg3 )
       
    78 
       
    79 #define LOG4( cstr_fmt, arg1, arg2, arg3, arg4 ) \
       
    80  iLog.WriteFormat( _L(cstr_fmt), arg1, arg2, arg3, arg4 )
       
    81 
       
    82 #define LOG_CODE( code ) code
       
    83 
       
    84 #else // not _DEBUG
       
    85 
       
    86 #define LOG_NAMES( cstr_log_dir, cstr_log_file )
       
    87 #define LOG_MEMBER_VARS
       
    88 #define LOG_CONSTRUCTL
       
    89 #define LOG_DESTRUCT
       
    90 #define LOG_OPEN
       
    91 #define LOG_CLOSE
       
    92 #define LOG_FLUSH
       
    93 #define LOG( cstr )
       
    94 #define LOG_DES( des )
       
    95 #define LOG1( cstr_fmt, arg1 )
       
    96 #define LOG2( cstr_fmt, arg1, arg2 )
       
    97 #define LOG3( cstr_fmt, arg1, arg2, arg3 )
       
    98 #define LOG4( cstr_fmt, arg1, arg2, arg3, arg4 )
       
    99 #define LOG_CODE( code )
       
   100 
       
   101 #endif // _DEBUG
       
   102 
       
   103 #endif  // WIDGETREGISTRY_H