messagingappbase/msgeditor/mediacontrolinc/MsgMediaControlLogging.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006 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 *     Logging macros for MsgEditorMediaControl.dll
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // ========== LOGGING MACROS ===============================
       
    22 
       
    23 #ifndef MSGMEDIACONTROLLOGGING_H
       
    24 #define MSGMEDIACONTROLLOGGING_H
       
    25 
       
    26 #ifdef USE_LOGGER
       
    27 
       
    28 #include <e32std.h>
       
    29 #include <e32def.h>
       
    30 #include <flogger.h>
       
    31 #include <msgasynccontrolobserver.h>
       
    32 
       
    33 #ifdef USE_RDEBUG
       
    34 
       
    35 _LIT(KMsgMediaControlLogDir,                "MsgEditor");
       
    36 _LIT(KMsgMediaControlLogFile,               "MsgMediaControl.txt");
       
    37 _LIT(KMsgMediaControlLogBanner,             "MsgMediaControl");
       
    38 _LIT(KMsgMediaControlLogEnterFn,            "MsgMediaControl: >> %S");
       
    39 _LIT(KMsgMediaControlLogLeaveFn,            "MsgMediaControl: << %S");
       
    40 _LIT(KMsgMediaControlLogWrite,              "MsgMediaControl: %S");
       
    41 _LIT(KMsgMediaControlLogTag,                "MsgMediaControl: ");
       
    42 _LIT(KMsgMediaControlLogExit,               "MsgMediaControl: Application exit");
       
    43 _LIT(KMsgMediaControlLogTimeFormatString,   "%H:%T:%S:%*C2");
       
    44 
       
    45 #define MSGMEDIACONTROLLOGGER_CREATE(a)          {RDebug::Print(KMsgMediaControlLogBanner);}
       
    46 #define MSGMEDIACONTROLLOGGER_DELETE             {RDebug::Print(KMsgMediaControlLogExit);}
       
    47 #define MSGMEDIACONTROLLOGGER_ENTERFN(a)         {_LIT(temp, a); RDebug::Print(KMsgMediaControlLogEnterFn, &temp);}
       
    48 #define MSGMEDIACONTROLLOGGER_LEAVEFN(a)         {_LIT(temp, a); RDebug::Print(KMsgMediaControlLogLeaveFn, &temp);}
       
    49 #define MSGMEDIACONTROLLOGGER_WRITE(a)           {_LIT(temp, a); RDebug::Print(KMsgMediaControlLogWrite, &temp);}
       
    50 #define MSGMEDIACONTROLLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KMsgMediaControlLogTimeFormatString ); buffer.Insert(0, temp); buffer.Insert(0, KMsgMediaControlLogTag); RDebug::Print(buffer); }
       
    51 #define MSGMEDIACONTROLLOGGER_WRITEF             RDebug::Print
       
    52 
       
    53 #else
       
    54 
       
    55 _LIT(KMsgMediaControlLogDir,                "MsgEditor");
       
    56 _LIT(KMsgMediaControlLogFile,               "MsgMediaControl.txt");
       
    57 _LIT(KMsgMediaControlLogBanner,             "MsgMediaControl");
       
    58 _LIT(KMsgMediaControlLogEnterFn,            "MsgMediaControl: >> %S");
       
    59 _LIT(KMsgMediaControlLogLeaveFn,            "MsgMediaControl: << %S");
       
    60 _LIT(KMsgMediaControlLogWrite,              "MsgMediaControl: %S");
       
    61 _LIT(KMsgMediaControlLogTag,                "MsgMediaControl: ");
       
    62 _LIT(KMsgMediaControlLogExit,               "MsgMediaControl: Application exit");
       
    63 _LIT(KMsgMediaControlLogTimeFormatString,   "%H:%T:%S:%*C2");
       
    64 
       
    65 #define MSGMEDIACONTROLLOGGER_CREATE(a)          {FCreate(a);}
       
    66 #define MSGMEDIACONTROLLOGGER_DELETE             {RFileLogger::Write(KMsgMediaControlLogDir, KMsgMediaControlLogFile, EFileLoggingModeAppend, KMsgMediaControlLogExit);}
       
    67 #define MSGMEDIACONTROLLOGGER_ENTERFN(a)         {_LIT(temp, a); RFileLogger::WriteFormat(KMsgMediaControlLogDir, KMsgMediaControlLogFile, EFileLoggingModeAppend, KMsgMediaControlLogEnterFn, &temp);}
       
    68 #define MSGMEDIACONTROLLOGGER_LEAVEFN(a)         {_LIT(temp, a); RFileLogger::WriteFormat(KMsgMediaControlLogDir, KMsgMediaControlLogFile, EFileLoggingModeAppend, KMsgMediaControlLogLeaveFn, &temp);}
       
    69 #define MSGMEDIACONTROLLOGGER_WRITE(a)           {_LIT(temp, a); RFileLogger::Write(KMsgMediaControlLogDir, KMsgMediaControlLogFile, EFileLoggingModeAppend, temp);}
       
    70 #define MSGMEDIACONTROLLOGGER_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KMsgMediaControlLogTimeFormatString ); buffer.Insert(0, temp); RFileLogger::Write(KMsgMediaControlLogDir, KMsgMediaControlLogFile, EFileLoggingModeAppend, buffer); }
       
    71 #define MSGMEDIACONTROLLOGGER_WRITEF             FwPrint
       
    72 // a=aFmt MUST contain %S, %d and %S in this order
       
    73 #define MSGMEDIACONTROLLOGGER_WRITEF_CONTROL_ERROR_STATE(a,b,c)  FPrintControlErrorState(a, iMediaControlType, b, c)
       
    74 // a=aFmt MUST contain %d and %S in this order
       
    75 #define MSGMEDIACONTROLLOGGER_WRITEF_ERROR_STATE(a,b,c)  FPrintErrorState(a,b,c)
       
    76 // a=aFmt MUST contain %d, %S in this order
       
    77 #define MSGMEDIACONTROLLOGGER_WRITEF_CONTROL_STATE(a,b)  FPrintControlState(a,iMediaControlType,b)
       
    78 #define MSGMEDIACONTROLLOGGER_WRITEF_CONTROL_STATE2(a,b,c)  FPrintControlState(a,b,c)
       
    79 
       
    80 inline void FwPrint(const TRefByValue<const TDesC> aFmt, ...)
       
    81     {
       
    82     VA_LIST list;
       
    83     VA_START(list,aFmt);
       
    84     RFileLogger::WriteFormat(KMsgMediaControlLogDir, KMsgMediaControlLogFile, EFileLoggingModeAppend, aFmt, list);
       
    85     }
       
    86 
       
    87 inline void FwPrint(const TDesC& aDes)
       
    88     {
       
    89     RFileLogger::WriteFormat(KMsgMediaControlLogDir, KMsgMediaControlLogFile, EFileLoggingModeAppend, aDes);
       
    90     }
       
    91 
       
    92 inline void FwHex(const TUint8* aPtr, TInt aLen)
       
    93     {
       
    94     RFileLogger::HexDump(KMsgMediaControlLogDir, KMsgMediaControlLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
       
    95     }
       
    96 
       
    97 inline void FwHex(const TDesC8& aDes)
       
    98     {
       
    99     FwHex(aDes.Ptr(), aDes.Length());
       
   100     }
       
   101 
       
   102 inline void FCreate(RFs& aFs)
       
   103     {
       
   104     TFileName path(_L("c:\\logs\\"));
       
   105     path.Append(KMsgMediaControlLogDir);
       
   106     path.Append(_L("\\"));
       
   107     aFs.MkDirAll(path);
       
   108     RFileLogger::WriteFormat(KMsgMediaControlLogDir, KMsgMediaControlLogFile, EFileLoggingModeOverwrite, KMsgMediaControlLogBanner);
       
   109     }
       
   110 
       
   111 inline void StateToDes(TInt aState, TDes& aDes)
       
   112     {
       
   113     switch ( aState )
       
   114         {
       
   115         case EMsgAsyncControlStateIdle:
       
   116             aDes.Copy(_L("EMsgMediaControlStateIdle"));
       
   117             break;
       
   118         case EMsgAsyncControlStateOpening:
       
   119             aDes.Copy(_L("EMsgMediaControlStateOpening"));
       
   120             break;
       
   121         case EMsgAsyncControlStateBuffering:
       
   122             aDes.Copy(_L("EMsgMediaControlStateBuffering"));
       
   123             break;
       
   124         case EMsgAsyncControlStateReady:
       
   125             aDes.Copy(_L("EMsgMediaControlStateReady"));
       
   126             break;
       
   127         case EMsgAsyncControlStateAboutToPlay:
       
   128             aDes.Copy(_L("EMsgMediaControlStateAboutToPlay"));
       
   129             break;
       
   130         case EMsgAsyncControlStatePlaying:
       
   131             aDes.Copy(_L("EMsgMediaControlStatePlaying"));
       
   132             break;
       
   133         case EMsgAsyncControlStatePaused:
       
   134             aDes.Copy(_L("EMsgMediaControlStatePaused"));
       
   135             break;
       
   136         case EMsgAsyncControlStateStopped:
       
   137             aDes.Copy(_L("EMsgMediaControlStateStopped"));
       
   138             break;
       
   139         case EMsgAsyncControlStateNoRights:
       
   140             aDes.Copy(_L("EMsgMediaControlStateNoRights"));
       
   141             break;
       
   142         case EMsgAsyncControlStateCorrupt:
       
   143             aDes.Copy(_L("EMsgMediaControlStateCorrupt"));
       
   144             break;
       
   145         default:
       
   146             aDes.Copy(_L("???Unknown state???"));
       
   147             break;
       
   148         }
       
   149     }
       
   150 
       
   151 inline void ControlToDes(TInt aControl, TDes& aDes)
       
   152     {
       
   153     switch ( aControl )
       
   154         {
       
   155         case EMsgComponentIdImage:
       
   156             aDes.Copy(_L("CMsgImageControl"));
       
   157             break;
       
   158         case EMsgComponentIdVideo:
       
   159             aDes.Copy(_L("CMsgVideoControl"));
       
   160             break;
       
   161         case EMsgComponentIdAudio:
       
   162             aDes.Copy(_L("CMsgAudioControl"));
       
   163             break;
       
   164         case EMsgComponentIdSvg:
       
   165             aDes.Copy(_L("CMsgSvgControl"));
       
   166             break;
       
   167         default:
       
   168             aDes.Copy(_L("???Unknown control???"));
       
   169             break;
       
   170         }
       
   171     }
       
   172 
       
   173 
       
   174 inline void FPrintControlErrorState(const TRefByValue<const TDesC> aFmt, TInt aControl, TInt aError, TInt aState)
       
   175     {
       
   176     TBuf<32> control;
       
   177     ControlToDes(aControl,control);
       
   178     TBuf<64> state;
       
   179     StateToDes(aState,state);
       
   180     FwPrint(aFmt,&control,aError,&state);
       
   181     }
       
   182 
       
   183 inline void FPrintControlState(const TRefByValue<const TDesC> aFmt, TInt aControl, TInt aState)
       
   184     {
       
   185     TBuf<32> control;
       
   186     ControlToDes(aControl,control);
       
   187     TBuf<64> state;
       
   188     StateToDes(aState,state);
       
   189     FwPrint(aFmt,&control,&state);
       
   190     }
       
   191 
       
   192 inline void FPrintErrorState(const TRefByValue<const TDesC> aFmt, TInt aError, TInt aState)
       
   193     {
       
   194     TBuf<64> state;
       
   195     StateToDes(aState,state);
       
   196     FwPrint(aFmt,aError,&state);
       
   197     }
       
   198 
       
   199 
       
   200 #endif // USE_RDEBUG
       
   201 
       
   202 #else // USE_LOGGER
       
   203 
       
   204 // dummy inline FPrint for MMSUIUTILSLOGGER_WRITEF macro.
       
   205 inline TInt FwPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { return 0; }
       
   206 
       
   207 #define MSGMEDIACONTROLLOGGER_CREATE(a)
       
   208 #define MSGMEDIACONTROLLOGGER_DELETE
       
   209 #define MSGMEDIACONTROLLOGGER_ENTERFN(a)
       
   210 #define MSGMEDIACONTROLLOGGER_LEAVEFN(a)
       
   211 #define MSGMEDIACONTROLLOGGER_WRITE(a)
       
   212 // if USE_LOGGER not defined this call to FPrint gets optimized away.
       
   213 #define MSGMEDIACONTROLLOGGER_WRITEF 1 ? 0 : FwPrint
       
   214 #define MSGMEDIACONTROLLOGGER_WRITE_TIMESTAMP(a)
       
   215 #define MSGMEDIACONTROLLOGGER_WRITEF_CONTROL_ERROR_STATE(a,b,c)
       
   216 #define MSGMEDIACONTROLLOGGER_WRITEF_ERROR_STATE(a,b,c) 
       
   217 #define MSGMEDIACONTROLLOGGER_WRITEF_CONTROL_STATE(a,b)
       
   218 
       
   219 #endif // USE_LOGGER
       
   220 
       
   221 #endif // MSGMEDIACONTROLLOGGING_H
       
   222 
       
   223 // =========================================================