messagingappbase/smilengine/xhtml/inc/xhtmlparserlogging.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:   XHTML Parserlogging macros.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef XHTMLPARSERLOGGING_H
       
    21 #define XHTMLPARSERLOGGING_H
       
    22 
       
    23 // ========== LOGGING MACROS ===============================
       
    24 
       
    25 #if defined( _DEBUG ) || defined( USE_LOGGER )
       
    26 
       
    27 #ifndef USE_LOGGER
       
    28 #define USE_LOGGER
       
    29 #endif 
       
    30 
       
    31 #include <e32std.h>
       
    32 #include <e32def.h>
       
    33 #include <eikenv.h>
       
    34 #include <flogger.h>
       
    35 
       
    36 #ifdef USE_RDEBUG
       
    37 
       
    38 _LIT( KXHTMLLogBanner,            "XHTML " );
       
    39 _LIT( KXHTMLLogEnterFn,           "XHTML: enter --> %S" );
       
    40 _LIT( KXHTMLLogLeaveFn,           "XHTML: leave <-- %S" );
       
    41 _LIT( KMEBLogWrite,             "XHTML: %S" );
       
    42 _LIT( KMEBLogTag,               "XHTML: " );
       
    43 _LIT( KXHTMLLogExit,              "XHTML: Application exit" );
       
    44 _LIT( KXHTMLLogTimeFormatString,  "%H:%T:%S:%*C2" );
       
    45 
       
    46 #define XHTMLLOG_CREATE             {RDebug::Print(KXHTMLLogBanner);}
       
    47 #define XHTMLLOG_DELETE             {RDebug::Print(KXHTMLLogExit);}
       
    48 #define XHTMLLOG_ENTERFN(a)         {_LIT(xhtmllog, a); RDebug::Print(KXHTMLLogEnterFn, &xhtmllog);}
       
    49 #define XHTMLLOG_LEAVEFN(a)         {_LIT(xhtmllog, a); RDebug::Print(KXHTMLLogLeaveFn, &xhtmllog);}
       
    50 #define XHTMLLOG_WRITE(a)           {_LIT(xhtmllog, a); RDebug::Print(KXHTMLLogWrite, &xhtmllog);}
       
    51 #define XHTMLLOG_WRITE_TIMESTAMP(a) {_LIT(xhtmllog, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KXHTMLLogTimeFormatString ); buffer.Insert(0, xhtmllog); buffer.Insert(0, KXHTMLLogTag); RDebug::Print(buffer); }
       
    52 #define XHTMLLOG_WRITEF             RDebug::Print
       
    53 #define XHTMLLOG_WRITEF8            RDebug::Print
       
    54 
       
    55 #else // USE_RDEBUG
       
    56 
       
    57 _LIT( KXHTMLLogDir,               "XHTML");
       
    58 _LIT( KXHTMLLogFile,              "XHTML.txt");
       
    59 _LIT8(KXHTMLLogBanner,            "XHTML ");
       
    60 _LIT8(KXHTMLLogEnterFn,           "XHTML: -> %S");
       
    61 _LIT8(KXHTMLLogLeaveFn,           "XHTML: <- %S");
       
    62 _LIT8(KXHTMLLogExit,              "XHTML: Application exit");
       
    63 _LIT( KXHTMLLogTimeFormatString,  "%H:%T:%S:%*C2");
       
    64 
       
    65 #define XHTMLLOG_CREATE             {FCreate();}
       
    66 #define XHTMLLOG_DELETE             {RFileLogger::Write(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeAppend, KXHTMLLogExit);}
       
    67 #define XHTMLLOG_ENTERFN(a)         {_LIT8(xhtmllog, a); RFileLogger::WriteFormat(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeAppend, KXHTMLLogEnterFn, &xhtmllog);}
       
    68 #define XHTMLLOG_LEAVEFN(a)         {_LIT8(xhtmllog, a); RFileLogger::WriteFormat(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeAppend, KXHTMLLogLeaveFn, &xhtmllog);}
       
    69 #define XHTMLLOG_WRITE(a)           {_LIT(xhtmllog, a); RFileLogger::Write(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeAppend, xhtmllog);}
       
    70 #define XHTMLLOG_WRITE_TIMESTAMP(a) {_LIT(xhtmllog, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KXHTMLLogTimeFormatString ); buffer.Insert(0, xhtmllog); RFileLogger::Write(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeAppend, buffer); }
       
    71 #define XHTMLLOG_WRITEF             FPrint
       
    72 #define XHTMLLOG_WRITEF8            FPrint8
       
    73 
       
    74 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...)
       
    75     {
       
    76     VA_LIST list;
       
    77     VA_START(list,aFmt);
       
    78     RFileLogger::WriteFormat(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeAppend, aFmt, list);
       
    79     }
       
    80 
       
    81 
       
    82 inline void FPrint8(const TRefByValue<const TDesC8> aFmt, ...)
       
    83     {
       
    84     VA_LIST list;
       
    85     VA_START(list,aFmt);
       
    86     RFileLogger::WriteFormat(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeAppend, aFmt, list);
       
    87     }
       
    88 
       
    89 
       
    90 inline void FPrint(const TDesC& aDes)
       
    91     {
       
    92     RFileLogger::WriteFormat(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeAppend, aDes);
       
    93     }
       
    94 
       
    95 inline void FHex(const TUint8* aPtr, TInt aLen)
       
    96     {
       
    97     RFileLogger::HexDump(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen);
       
    98     }
       
    99 
       
   100 inline void FHex(const TDesC8& aDes)
       
   101     {
       
   102     FHex(aDes.Ptr(), aDes.Length());
       
   103     }
       
   104 
       
   105 inline void FCreate()
       
   106     {
       
   107     TFileName path(_L("c:\\logs\\"));
       
   108     path.Append(KXHTMLLogDir);
       
   109     path.Append(_L("\\"));
       
   110     RFs& fs = CEikonEnv::Static()->FsSession();
       
   111     fs.MkDirAll(path);
       
   112     RFileLogger::WriteFormat(KXHTMLLogDir, KXHTMLLogFile, EFileLoggingModeOverwrite, KXHTMLLogBanner);
       
   113     }
       
   114 
       
   115 #endif // USE_RDEBUG
       
   116 
       
   117 #else // not logging
       
   118 
       
   119 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) {};
       
   120 inline void FPrint8(const TRefByValue<const TDesC8> /*aFmt*/, ...) {};
       
   121 
       
   122 #define XHTMLLOG_CREATE
       
   123 #define XHTMLLOG_DELETE
       
   124 #define XHTMLLOG_ENTERFN(a)
       
   125 #define XHTMLLOG_LEAVEFN(a)
       
   126 #define XHTMLLOG_WRITE(a)
       
   127 #define XHTMLLOG_WRITEF 1 ? ((void)0) : FPrint
       
   128 #define XHTMLLOG_WRITEF8 1 ? ((void)0) : FPrint8
       
   129 #define XHTMLLOG_WRITE_TIMESTAMP(a)
       
   130 
       
   131 #endif // logging
       
   132 
       
   133 #endif // XHTMLPARSERLOGGING_H
       
   134 
       
   135 // End of File