mmappcomponents/videoplaylistutility/inc/videoplaylistutility_log.h
branchRCL_3
changeset 9 bee149131e4b
parent 0 a2952bb97e68
child 25 d881023c13eb
child 55 6c1dfe4da5dd
equal deleted inserted replaced
4:d45095c2f4f3 9:bee149131e4b
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  Debug print macros
    14 * Description:  Debug print macros
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 2 %
    18 // Version : %version: 3 %
    19 
       
    20 
       
    21 
    19 
    22 
    20 
    23 #ifndef VIDEOPLAYLISTUTILITY_LOG_H
    21 #ifndef VIDEOPLAYLISTUTILITY_LOG_H
    24 #define VIDEOPLAYLISTUTILITY_LOG_H
    22 #define VIDEOPLAYLISTUTILITY_LOG_H
       
    23 
    25 
    24 
    26 // INCLUDES
    25 // INCLUDES
    27 #include <e32std.h>
    26 #include <e32std.h>
    28 #include <e32svr.h>
    27 #include <e32svr.h>
    29 #include <e32des16.h>
    28 #include <e32des16.h>
    30 #include <e32property.h>
    29 #include <e32property.h>
    31 #include <flogger.h>
       
    32 #include <e32def.h>
    30 #include <e32def.h>
    33 
    31 
    34 
    32 
    35 
    33 //
    36 // #define _VPU_FILE_LOGGING_
    34 //  MACROS
    37 
    35 //
    38 #ifdef _DEBUG
    36 #ifdef _DEBUG
    39     #define VPU_DEBUG RDebug::Print
    37     #define VIDEOPLAYLISTUTILITY_DEBUG        TVideoPlaylistUtilityLog::VideoPlaylistUtilityLog
       
    38     #define VIDEOPLAYLISTUTILITY_ENTER_EXIT   TEnterExitLog _s
    40 #else
    39 #else
    41     #ifdef _VPU_FILE_LOGGING_
    40     #define VIDEOPLAYLISTUTILITY_DEBUG        TVideoPlaylistUtilityLog::NullLog
    42         #define VPU_DEBUG VideoPlaylistUtilityDebug::FileLog
    41     #define VIDEOPLAYLISTUTILITY_ENTER_EXIT   TVideoPlaylistUtilityLog::NullLog
    43     #else
    42 #endif
    44         #define VPU_DEBUG RDebug::Print
       
    45     #endif
       
    46 #endif 
       
    47 
    43 
    48 
    44 
    49 class VideoPlaylistUtilityDebug
    45 class TVideoPlaylistUtilityLog : public TDes16Overflow
    50 {
    46 {
    51     public:
    47     public:
       
    48 
    52         inline static void NullLog( TRefByValue<const TDesC16> /*aFmt*/, ... )
    49         inline static void NullLog( TRefByValue<const TDesC16> /*aFmt*/, ... )
    53         {
    50         {
    54         }
    51         }
    55 
    52 
    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, ... )
    53         inline static void VideoPlaylistUtilityLog( TRefByValue<const TDesC16> aFmt, ... )
    79         {
    54         {
    80             TBuf< 512 > buffer;
    55             TBuf< 512 > buffer;
    81             
    56 
    82             VA_LIST list;
    57             VA_LIST list;
    83             VA_START( list, aFmt );
    58             VA_START( list, aFmt );
    84             buffer.AppendFormatList( aFmt, list );
    59             buffer.AppendFormatList( aFmt, list );
    85             VA_END(list);
    60             VA_END(list);
    86             
    61 
    87             VPU_DEBUG(_L("#VideoPlaylistUtility# %S"), &buffer );
    62             RDebug::Print(_L("#VideoPlaylistUtility# %S"), &buffer );
    88         }
    63         }
    89 };
    64 };
    90 
    65 
    91 class TEnterExitLog : public TDes16Overflow
    66 class TEnterExitLog : public TDes16Overflow
    92 {
    67 {
    93     public:
    68     public:
    94         
    69 
    95         void Overflow(TDes16& /*aDes*/)
    70         void Overflow(TDes16& /*aDes*/)
    96         {
    71         {
    97             VPU_DEBUG(_L("%S Logging Overflow"), &iFunctionName);
    72             RDebug::Print(_L("%S Logging Overflow"), &iFunctionName);
    98         }
    73         }
    99 
    74 
   100         TEnterExitLog( TRefByValue<const TDesC> aFunctionName,
    75         TEnterExitLog( TRefByValue<const TDesC> aFunctionName,
   101                        TRefByValue<const TDesC> aFmt, ... )
    76                        TRefByValue<const TDesC> aFmt, ... )
   102         {
    77         {
   103             iFunctionName = HBufC::New( TDesC(aFunctionName).Length() );
    78             iFunctionName = HBufC::New( TDesC(aFunctionName).Length() );
   104             
    79 
   105             if ( iFunctionName )
    80             if ( iFunctionName )
   106             {
    81             {
   107                 iFunctionName->Des().Copy(aFunctionName);
    82                 iFunctionName->Des().Copy(aFunctionName);
   108             }
    83             }
   109             
    84 
   110             TBuf< 512 > buffer;
    85             TBuf< 512 > buffer;
   111             
    86 
   112             VA_LIST list;
    87             VA_LIST list;
   113             VA_START( list, aFmt );
    88             VA_START( list, aFmt );
   114             buffer.AppendFormatList( aFmt, list, this );
    89             buffer.AppendFormatList( aFmt, list, this );
   115             VA_END(list);
    90             VA_END(list);
   116             
    91 
   117             VPU_DEBUG(_L("#VideoPlaylistUtility# --> %S %S"), iFunctionName, &buffer );
    92             RDebug::Print(_L("#VideoPlaylistUtility# --> %S %S"), iFunctionName, &buffer );
   118         }
    93         }
   119         
    94 
   120         TEnterExitLog( TRefByValue<const TDesC> aFunctionName )
    95         TEnterExitLog( TRefByValue<const TDesC> aFunctionName )
   121         {
    96         {
   122             iFunctionName = HBufC::New( TDesC(aFunctionName).Length() );
    97             iFunctionName = HBufC::New( TDesC(aFunctionName).Length() );
   123             
    98 
   124             if ( iFunctionName )
    99             if ( iFunctionName )
   125             {
   100             {
   126                 iFunctionName->Des().Copy(aFunctionName);
   101                 iFunctionName->Des().Copy(aFunctionName);
   127             }
   102             }
   128             
   103 
   129             VPU_DEBUG(_L("#VideoPlaylistUtility# --> %S"), iFunctionName );
   104             RDebug::Print(_L("#VideoPlaylistUtility# --> %S"), iFunctionName );
   130         }
   105         }
   131         
   106 
   132         ~TEnterExitLog()
   107         ~TEnterExitLog()
   133         {
   108         {
   134             VPU_DEBUG(_L("#VideoPlaylistUtility# <-- %S"), iFunctionName );
   109             RDebug::Print(_L("#VideoPlaylistUtility# <-- %S"), iFunctionName );
   135             delete iFunctionName;
   110             delete iFunctionName;
   136         }
   111         }
   137         
   112 
   138     private:
   113     private:
   139         HBufC*    iFunctionName;
   114         HBufC*    iFunctionName;
   140 };
   115 };
       
   116 
   141 
   117 
   142 _LIT(_KVPUErrorInfo, "#VideoPlaylistUtility# Error : error %d file %s line %d");
   118 _LIT(_KVPUErrorInfo, "#VideoPlaylistUtility# Error : error %d file %s line %d");
   143 
   119 
   144 #define VIDEOPLAYLISTUTILITY_S(a) _S(a)
   120 #define VIDEOPLAYLISTUTILITY_S(a) _S(a)
   145 
   121