contentpublishingsrv/contentpublishingutils/contentpublishingdebug/inc/cpdebug.h
changeset 73 4bc7b118b3df
parent 66 32469d7d46ff
child 80 397d00875918
child 81 5ef31a21fdd5
equal deleted inserted replaced
66:32469d7d46ff 73:4bc7b118b3df
     1 /*
       
     2 * Copyright (c) 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:  Debug printing to a log file
       
    15  *
       
    16 */
       
    17 
       
    18 #ifndef C_CP_DEBUG_H
       
    19 #define C_CP_DEBUG_H
       
    20 
       
    21 // INCLUDES
       
    22 
       
    23 #include <e32base.h>
       
    24 #ifdef CONTENT_PUBLISHER_DEBUG
       
    25 #include <f32file.h>
       
    26 
       
    27 _LIT(KCPDebugDirName, "contentpublisher" );
       
    28 _LIT(KCPDebugFileName, "c:\\contentpublisher.txt" );
       
    29 _LIT(KCPDebugFileName2, "c:\\server.txt" );
       
    30 
       
    31 /**
       
    32  *  Content publisher debug
       
    33  *
       
    34  *
       
    35  *  @lib cpdebug.lib
       
    36  *  @since  S60 v3.2
       
    37  */
       
    38 NONSHARABLE_CLASS( CCPDebug ): public CBase
       
    39     {
       
    40 public:
       
    41 
       
    42     IMPORT_C static CCPDebug* NewLC( const TDesC& aFile );
       
    43 
       
    44     IMPORT_C static CCPDebug* NewL( const TDesC& aFile );
       
    45 
       
    46     virtual ~CCPDebug();
       
    47 
       
    48     /**
       
    49      * Determines whether CCPDebug is exist .		
       
    50      */
       
    51     IMPORT_C static TBool Enable();
       
    52 
       
    53     /**
       
    54      * Enables or disables Printf message logging to a file.		
       
    55      * @param aEnable Set to true to enable logging, false to disable.
       
    56      */
       
    57     IMPORT_C static void EnableLogging(TBool aEnable);
       
    58 
       
    59     /**
       
    60      * Print debug text to the file (c:\\contentpublisher.txt). 
       
    61      *
       
    62      */
       
    63     IMPORT_C static void Printf(TRefByValue<const TDesC8> aFormat, ...);
       
    64 
       
    65 private:
       
    66 
       
    67     CCPDebug();
       
    68 
       
    69     void ConstructL( const TDesC& aFile );
       
    70 
       
    71     /**
       
    72      * Returns a pointer to the thread-local data struct.
       
    73      */
       
    74     IMPORT_C static struct DebugData* Data();
       
    75 
       
    76 private: // data
       
    77 
       
    78     /**
       
    79      * Thread local storage for this DLL, as we cannot declare static
       
    80      * global variables in Symbian.
       
    81      */
       
    82     struct DebugData* iData;
       
    83     
       
    84     };
       
    85 
       
    86 #define CP_DEBUG(s)    CCPDebug::Printf(s)
       
    87 
       
    88 /**
       
    89  * Thread local storage space. Writable static data is not supported in
       
    90  * Symbian, so static data is stored in this struct.
       
    91  */
       
    92 struct DebugData
       
    93     {
       
    94     RFile iLogFile;
       
    95     RFs iFs;
       
    96     TBool iLogEnabled;
       
    97     TTime iFirstUpdateTime;
       
    98     RBuf iFileName;
       
    99     };
       
   100 
       
   101 #else
       
   102 
       
   103 #define CP_DEBUG(s) 
       
   104 
       
   105 #endif
       
   106 
       
   107 #endif // C_CP_DEBUG_H