javacommons/utils/inc.s60/jdebug_omj.h
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef JDEBUG_OMJ_H
       
    19 #define JDEBUG_OMJ_H
       
    20 
       
    21 #define JAVA_OLD_STYLE_LOGGING_ON
       
    22 
       
    23 #include <flogger.h>
       
    24 
       
    25 _LIT(KLogDirectory, "java");
       
    26 _LIT(KLogFileName, "java.txt");
       
    27 
       
    28 // Strings for flogger directory and file names
       
    29 #include <string>
       
    30 
       
    31 #define DEBUG_START { char* _Dbg_str = new char[2500]; sprintf( _Dbg_str,
       
    32 #define DEBUG_END   );\
       
    33                     TPtrC8 ptr( (TUint8*)_Dbg_str );\
       
    34                     HBufC* buf = HBufC::New(ptr.Length() + 1);\
       
    35                     if (buf) {\
       
    36                         TPtr16 tmpPtr = buf->Des();\
       
    37                         tmpPtr.Copy(ptr);\
       
    38                         tmpPtr.ZeroTerminate();\
       
    39                     }\
       
    40                     RFileLogger::Write(KLogDirectory, KLogFileName, EFileLoggingModeAppend,*buf);\
       
    41                     delete buf;\
       
    42                     delete _Dbg_str;\
       
    43                 }
       
    44 #ifdef JAVA_OLD_STYLE_LOGGING_ON
       
    45 
       
    46 // these macros are documented below.
       
    47 #define DEBUG( msg ) DEBUG_START msg DEBUG_END
       
    48 #define DEBUG_STR( msg, string ) DEBUG_START msg, string DEBUG_END
       
    49 #define DEBUG_STR_INT( msg, string, num ) DEBUG_START msg, string, num DEBUG_END
       
    50 #define DEBUG_INT( msg, num ) DEBUG_START msg, num DEBUG_END
       
    51 #define DEBUG_INT2( msg, num, num2 ) DEBUG_START msg, num, num2 DEBUG_END
       
    52 #define DEBUG_INT3( msg, num, num2, num3 ) DEBUG_START msg, num, num2, num3 DEBUG_END
       
    53 #define DEBUG_INT4( msg, num, num2, num3, num4 ) DEBUG_START msg, num, num2, num3, num4 DEBUG_END
       
    54 #define DEBUG_INT5( msg, num, num2, num3, num4, num5) DEBUG_START msg, num, num2, num3, num4, num5 DEBUG_END
       
    55 #define DEBUG_INT6( msg, num, num2, num3, num4, num5, num6 ) DEBUG_START msg, num, num2, num3, num4, num5, num6 DEBUG_END
       
    56 
       
    57 #else
       
    58 
       
    59 #define DEBUG( msg )
       
    60 #define DEBUG_STR( msg, string )
       
    61 #define DEBUG_STR_INT( msg, string )
       
    62 #define DEBUG_INT( msg, num )
       
    63 #define DEBUG_INT2( msg, num, num2 )
       
    64 #define DEBUG_INT3( msg, num, num2, num3 )
       
    65 #define DEBUG_INT4( msg, num, num2, num3, num4 )
       
    66 #define DEBUG_INT5( msg, num, num2, num3, num4, num5 )
       
    67 #define DEBUG_INT6( msg, num, num2, num3, num4, num5, num6 )
       
    68 #endif // JAVA_OLD_STYLE_LOGGING_ON
       
    69 
       
    70 #define ERROR( msg ) RFileLogger::Write(KLogDirectory, KLogFileName, EFileLoggingModeAppend, _L(msg))
       
    71 #define ERROR_INT( msg, num ) RFileLogger::WriteFormat(KLogDirectory, KLogFileName, EFileLoggingModeAppend,_L(msg), num )
       
    72 #define ERROR_STR( msg, string )  DEBUG_START msg, string DEBUG_END
       
    73 
       
    74 #endif // JDEBUG_OMJ_H
       
    75