dependencies/uncategorized/cpdebug.h
author Kashif.sayed
Thu, 25 Mar 2010 23:48:15 +0530
branchv5backport
changeset 25 1161e0025932
permissions -rw-r--r--
.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25
Kashif.sayed
parents:
diff changeset
     1
/*
Kashif.sayed
parents:
diff changeset
     2
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
Kashif.sayed
parents:
diff changeset
     3
* All rights reserved.
Kashif.sayed
parents:
diff changeset
     4
* This component and the accompanying materials are made available
Kashif.sayed
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
Kashif.sayed
parents:
diff changeset
     6
* which accompanies this distribution, and is available
Kashif.sayed
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
Kashif.sayed
parents:
diff changeset
     8
*
Kashif.sayed
parents:
diff changeset
     9
* Initial Contributors:
Kashif.sayed
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
Kashif.sayed
parents:
diff changeset
    11
*
Kashif.sayed
parents:
diff changeset
    12
* Contributors:
Kashif.sayed
parents:
diff changeset
    13
*
Kashif.sayed
parents:
diff changeset
    14
* Description:  Debug printing to a log file
Kashif.sayed
parents:
diff changeset
    15
 *
Kashif.sayed
parents:
diff changeset
    16
*/
Kashif.sayed
parents:
diff changeset
    17
Kashif.sayed
parents:
diff changeset
    18
#ifndef C_CP_DEBUG_H
Kashif.sayed
parents:
diff changeset
    19
#define C_CP_DEBUG_H
Kashif.sayed
parents:
diff changeset
    20
Kashif.sayed
parents:
diff changeset
    21
// INCLUDES
Kashif.sayed
parents:
diff changeset
    22
Kashif.sayed
parents:
diff changeset
    23
#include <e32base.h>
Kashif.sayed
parents:
diff changeset
    24
#ifdef CONTENT_PUBLISHER_DEBUG
Kashif.sayed
parents:
diff changeset
    25
#include <f32file.h>
Kashif.sayed
parents:
diff changeset
    26
Kashif.sayed
parents:
diff changeset
    27
_LIT(KCPDebugDirName, "contentpublisher" );
Kashif.sayed
parents:
diff changeset
    28
_LIT(KCPDebugFileName, "c:\\contentpublisher.txt" );
Kashif.sayed
parents:
diff changeset
    29
_LIT(KCPDebugFileName2, "c:\\server.txt" );
Kashif.sayed
parents:
diff changeset
    30
Kashif.sayed
parents:
diff changeset
    31
/**
Kashif.sayed
parents:
diff changeset
    32
 *  Content publisher debug
Kashif.sayed
parents:
diff changeset
    33
 *
Kashif.sayed
parents:
diff changeset
    34
 *
Kashif.sayed
parents:
diff changeset
    35
 *  @lib cpdebug.lib
Kashif.sayed
parents:
diff changeset
    36
 *  @since  S60 v3.2
Kashif.sayed
parents:
diff changeset
    37
 */
Kashif.sayed
parents:
diff changeset
    38
NONSHARABLE_CLASS( CCPDebug ): public CBase
Kashif.sayed
parents:
diff changeset
    39
    {
Kashif.sayed
parents:
diff changeset
    40
public:
Kashif.sayed
parents:
diff changeset
    41
Kashif.sayed
parents:
diff changeset
    42
    IMPORT_C static CCPDebug* NewLC( const TDesC& aFile );
Kashif.sayed
parents:
diff changeset
    43
Kashif.sayed
parents:
diff changeset
    44
    IMPORT_C static CCPDebug* NewL( const TDesC& aFile );
Kashif.sayed
parents:
diff changeset
    45
Kashif.sayed
parents:
diff changeset
    46
    virtual ~CCPDebug();
Kashif.sayed
parents:
diff changeset
    47
Kashif.sayed
parents:
diff changeset
    48
    /**
Kashif.sayed
parents:
diff changeset
    49
     * Determines whether CCPDebug is exist .		
Kashif.sayed
parents:
diff changeset
    50
     */
Kashif.sayed
parents:
diff changeset
    51
    IMPORT_C static TBool Enable();
Kashif.sayed
parents:
diff changeset
    52
Kashif.sayed
parents:
diff changeset
    53
    /**
Kashif.sayed
parents:
diff changeset
    54
     * Enables or disables Printf message logging to a file.		
Kashif.sayed
parents:
diff changeset
    55
     * @param aEnable Set to true to enable logging, false to disable.
Kashif.sayed
parents:
diff changeset
    56
     */
Kashif.sayed
parents:
diff changeset
    57
    IMPORT_C static void EnableLogging(TBool aEnable);
Kashif.sayed
parents:
diff changeset
    58
Kashif.sayed
parents:
diff changeset
    59
    /**
Kashif.sayed
parents:
diff changeset
    60
     * Print debug text to the file (c:\\contentpublisher.txt). 
Kashif.sayed
parents:
diff changeset
    61
     *
Kashif.sayed
parents:
diff changeset
    62
     */
Kashif.sayed
parents:
diff changeset
    63
    IMPORT_C static void Printf(TRefByValue<const TDesC8> aFormat, ...);
Kashif.sayed
parents:
diff changeset
    64
Kashif.sayed
parents:
diff changeset
    65
private:
Kashif.sayed
parents:
diff changeset
    66
Kashif.sayed
parents:
diff changeset
    67
    CCPDebug();
Kashif.sayed
parents:
diff changeset
    68
Kashif.sayed
parents:
diff changeset
    69
    void ConstructL( const TDesC& aFile );
Kashif.sayed
parents:
diff changeset
    70
Kashif.sayed
parents:
diff changeset
    71
    /**
Kashif.sayed
parents:
diff changeset
    72
     * Returns a pointer to the thread-local data struct.
Kashif.sayed
parents:
diff changeset
    73
     */
Kashif.sayed
parents:
diff changeset
    74
    IMPORT_C static struct DebugData* Data();
Kashif.sayed
parents:
diff changeset
    75
Kashif.sayed
parents:
diff changeset
    76
private: // data
Kashif.sayed
parents:
diff changeset
    77
Kashif.sayed
parents:
diff changeset
    78
    /**
Kashif.sayed
parents:
diff changeset
    79
     * Thread local storage for this DLL, as we cannot declare static
Kashif.sayed
parents:
diff changeset
    80
     * global variables in Symbian.
Kashif.sayed
parents:
diff changeset
    81
     */
Kashif.sayed
parents:
diff changeset
    82
    struct DebugData* iData;
Kashif.sayed
parents:
diff changeset
    83
    
Kashif.sayed
parents:
diff changeset
    84
    };
Kashif.sayed
parents:
diff changeset
    85
Kashif.sayed
parents:
diff changeset
    86
#define CP_DEBUG(s)    CCPDebug::Printf(s)
Kashif.sayed
parents:
diff changeset
    87
Kashif.sayed
parents:
diff changeset
    88
/**
Kashif.sayed
parents:
diff changeset
    89
 * Thread local storage space. Writable static data is not supported in
Kashif.sayed
parents:
diff changeset
    90
 * Symbian, so static data is stored in this struct.
Kashif.sayed
parents:
diff changeset
    91
 */
Kashif.sayed
parents:
diff changeset
    92
struct DebugData
Kashif.sayed
parents:
diff changeset
    93
    {
Kashif.sayed
parents:
diff changeset
    94
    RFile iLogFile;
Kashif.sayed
parents:
diff changeset
    95
    RFs iFs;
Kashif.sayed
parents:
diff changeset
    96
    TBool iLogEnabled;
Kashif.sayed
parents:
diff changeset
    97
    TTime iFirstUpdateTime;
Kashif.sayed
parents:
diff changeset
    98
    RBuf iFileName;
Kashif.sayed
parents:
diff changeset
    99
    };
Kashif.sayed
parents:
diff changeset
   100
Kashif.sayed
parents:
diff changeset
   101
#else
Kashif.sayed
parents:
diff changeset
   102
Kashif.sayed
parents:
diff changeset
   103
#define CP_DEBUG(s) 
Kashif.sayed
parents:
diff changeset
   104
Kashif.sayed
parents:
diff changeset
   105
#endif
Kashif.sayed
parents:
diff changeset
   106
Kashif.sayed
parents:
diff changeset
   107
#endif // C_CP_DEBUG_H