mmappcomponents/videoplaylistutility/inc/videoplaylistutility_log.h
changeset 0 a2952bb97e68
child 9 bee149131e4b
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     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:  Debug print macros
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 2 %
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef VIDEOPLAYLISTUTILITY_LOG_H
       
    24 #define VIDEOPLAYLISTUTILITY_LOG_H
       
    25 
       
    26 // INCLUDES
       
    27 #include <e32std.h>
       
    28 #include <e32svr.h>
       
    29 #include <e32des16.h>
       
    30 #include <e32property.h>
       
    31 #include <flogger.h>
       
    32 #include <e32def.h>
       
    33 
       
    34 
       
    35 
       
    36 // #define _VPU_FILE_LOGGING_
       
    37 
       
    38 #ifdef _DEBUG
       
    39     #define VPU_DEBUG RDebug::Print
       
    40 #else
       
    41     #ifdef _VPU_FILE_LOGGING_
       
    42         #define VPU_DEBUG VideoPlaylistUtilityDebug::FileLog
       
    43     #else
       
    44         #define VPU_DEBUG RDebug::Print
       
    45     #endif
       
    46 #endif 
       
    47 
       
    48 
       
    49 class VideoPlaylistUtilityDebug
       
    50 {
       
    51     public:
       
    52         inline static void NullLog( TRefByValue<const TDesC16> /*aFmt*/, ... )
       
    53         {
       
    54         }
       
    55 
       
    56         inline static void FileLog( TRefByValue<const TDesC16> aFmt, ... )
       
    57         {
       
    58             VA_LIST list;
       
    59             VA_START(list,aFmt);
       
    60             RFileLogger::WriteFormat( _L("VideoPlaylistUtility"), 
       
    61                                       _L("videoplaylistutility.log"),
       
    62                                       EFileLoggingModeAppend,
       
    63                                       aFmt,
       
    64                                       list );
       
    65         }
       
    66 };
       
    67 
       
    68 
       
    69 
       
    70 // MACROS
       
    71 #define VIDEOPLAYLISTUTILITY_DEBUG             TVideoPlaylistUtilityLog::VideoPlaylistUtilityLog
       
    72 #define VIDEOPLAYLISTUTILITY_ENTER_EXIT        TEnterExitLog _s
       
    73 
       
    74 class TVideoPlaylistUtilityLog : public TDes16Overflow
       
    75 {
       
    76     public:
       
    77         
       
    78         inline static void VideoPlaylistUtilityLog( TRefByValue<const TDesC16> aFmt, ... )
       
    79         {
       
    80             TBuf< 512 > buffer;
       
    81             
       
    82             VA_LIST list;
       
    83             VA_START( list, aFmt );
       
    84             buffer.AppendFormatList( aFmt, list );
       
    85             VA_END(list);
       
    86             
       
    87             VPU_DEBUG(_L("#VideoPlaylistUtility# %S"), &buffer );
       
    88         }
       
    89 };
       
    90 
       
    91 class TEnterExitLog : public TDes16Overflow
       
    92 {
       
    93     public:
       
    94         
       
    95         void Overflow(TDes16& /*aDes*/)
       
    96         {
       
    97             VPU_DEBUG(_L("%S Logging Overflow"), &iFunctionName);
       
    98         }
       
    99 
       
   100         TEnterExitLog( TRefByValue<const TDesC> aFunctionName,
       
   101                        TRefByValue<const TDesC> aFmt, ... )
       
   102         {
       
   103             iFunctionName = HBufC::New( TDesC(aFunctionName).Length() );
       
   104             
       
   105             if ( iFunctionName )
       
   106             {
       
   107                 iFunctionName->Des().Copy(aFunctionName);
       
   108             }
       
   109             
       
   110             TBuf< 512 > buffer;
       
   111             
       
   112             VA_LIST list;
       
   113             VA_START( list, aFmt );
       
   114             buffer.AppendFormatList( aFmt, list, this );
       
   115             VA_END(list);
       
   116             
       
   117             VPU_DEBUG(_L("#VideoPlaylistUtility# --> %S %S"), iFunctionName, &buffer );
       
   118         }
       
   119         
       
   120         TEnterExitLog( TRefByValue<const TDesC> aFunctionName )
       
   121         {
       
   122             iFunctionName = HBufC::New( TDesC(aFunctionName).Length() );
       
   123             
       
   124             if ( iFunctionName )
       
   125             {
       
   126                 iFunctionName->Des().Copy(aFunctionName);
       
   127             }
       
   128             
       
   129             VPU_DEBUG(_L("#VideoPlaylistUtility# --> %S"), iFunctionName );
       
   130         }
       
   131         
       
   132         ~TEnterExitLog()
       
   133         {
       
   134             VPU_DEBUG(_L("#VideoPlaylistUtility# <-- %S"), iFunctionName );
       
   135             delete iFunctionName;
       
   136         }
       
   137         
       
   138     private:
       
   139         HBufC*    iFunctionName;
       
   140 };
       
   141 
       
   142 _LIT(_KVPUErrorInfo, "#VideoPlaylistUtility# Error : error %d file %s line %d");
       
   143 
       
   144 #define VIDEOPLAYLISTUTILITY_S(a) _S(a)
       
   145 
       
   146 #define VIDEOPLAYLISTUTILITY_ERROR_LOG(aErr) \
       
   147     {\
       
   148         if (aErr) \
       
   149             VIDEOPLAYLISTUTILITY_DEBUG(_KVPUErrorInfo, aErr, VIDEOPLAYLISTUTILITY_S(__FILE__), __LINE__);\
       
   150     }
       
   151 
       
   152 #define VIDEOPLAYLISTUTILITY_TRAP(_r, _s) TRAP(_r,_s);VIDEOPLAYLISTUTILITY_ERROR_LOG(_r);
       
   153 #define VIDEOPLAYLISTUTILITY_TRAPD(_r, _s) TRAPD(_r,_s);VIDEOPLAYLISTUTILITY_ERROR_LOG(_r);
       
   154 
       
   155 #endif  // VIDEOPLAYLISTUTILITY_LOG_H
       
   156 
       
   157 // End of File