email/imap4mtm/imaputils/inc/cimaplogger.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __CIMAPLOGGER_H__
       
    17 #define __CIMAPLOGGER_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <f32file.h>
       
    21 #include "cimaputils.h"
       
    22 
       
    23 const TInt KDefaultLog = 0;
       
    24 
       
    25 #ifdef _DEBUG
       
    26 #define __IMAP_LOGGING
       
    27 #endif //_DEBUG
       
    28 
       
    29 #ifdef __IMAP_LOGGING
       
    30 
       
    31 #define __LOG_CREATE_DEFAULT(a) CImapUtils::GetRef().Logger().CreateDefaultLog(a)
       
    32 #define __LOG_CREATE_STANDARD(a,b) CImapUtils::GetRef().Logger().CreateStandardLog(a,b)
       
    33 #define __LOG_CLOSE(a) CImapUtils::GetRef().Logger().CloseLog(a)
       
    34 #define __LOG_TEXT(a,b) CImapUtils::GetRef().Logger().LogText(a,b)
       
    35 #define __LOG_DATA_IN(a,b) CImapUtils::GetRef().Logger().LogDataIn(a,b)
       
    36 #define __LOG_DATA_OUT(a,b) CImapUtils::GetRef().Logger().LogDataOut(a,b)
       
    37 #define __LOG_FORMAT(a) CImapUtils::GetRef().Logger().LogFormat a
       
    38 #define __LOG_ON(a,b) CImapUtils::GetRef().Logger().LogOn(a,b)
       
    39 
       
    40 #else //__IMAP_LOGGING
       
    41 
       
    42 #define __LOG_CREATE_DEFAULT(a)
       
    43 #define __LOG_CREATE_STANDARD(a,b)
       
    44 #define __LOG_CLOSE(a)
       
    45 #define __LOG_TEXT(a,b)
       
    46 #define __LOG_DATA_IN(a,b)
       
    47 #define __LOG_DATA_OUT(a,b)
       
    48 #define __LOG_FORMAT(a)
       
    49 #define __LOG_ON(a,b)
       
    50 
       
    51 #endif //__IMAP_LOGGING
       
    52 
       
    53 /**
       
    54 @internalTechnology
       
    55 @prototype
       
    56 */
       
    57 class CImapLogger : public CBase, TDes8Overflow
       
    58 	{
       
    59 public:
       
    60 	static CImapLogger* NewL();
       
    61 	~CImapLogger();
       
    62 
       
    63 	IMPORT_C void CreateDefaultLog(const TDesC& aFilePartName);
       
    64 	IMPORT_C void CreateStandardLog(const TDesC& aFilePartName, TInt& aLogId);
       
    65 	IMPORT_C void CloseLog(TInt aFilePos);
       
    66 	IMPORT_C void LogText(TInt aFilePos, char const* aText);
       
    67 	IMPORT_C void LogText(TInt aFilePos, const TDesC8& aText);
       
    68 	IMPORT_C void LogDataIn(TInt aFilePos, const TDesC8& aText);
       
    69 	IMPORT_C void LogDataOut(TInt aFilePos, const TDesC8& aText);
       
    70 	IMPORT_C void LogFormat(TInt aFilePos, char const* aFmt, ...);
       
    71 	IMPORT_C void LogFormat(TInt aFilePos, TRefByValue<const TDesC8> aFmt, ...);
       
    72 	IMPORT_C void LogOn(TInt aFilePos, TBool aLoggingOn);
       
    73 
       
    74 private:
       
    75 	CImapLogger();
       
    76 	void ConstructL();
       
    77 
       
    78 	void DoCreateDefaultLogL(const TDesC& aFilePartName);
       
    79 	void DoCreateStandardLogL(const TDesC& aFilePartName, TInt& aLogId);
       
    80 	void LogData(TInt aFilePos, const TDesC8& aText, const TDesC8& aFmt);
       
    81 	void LogFormat(TInt aFilePos, VA_LIST& aList, TRefByValue<const TDesC8> aFmt);
       
    82 
       
    83 	// from TDes8Overflow
       
    84 	void Overflow(TDes8& aDes);
       
    85 
       
    86 private:
       
    87 	struct TLogFileInfo
       
    88 		{
       
    89 		RFile iFile;
       
    90 		TBool iLoggingOn;
       
    91 		};
       
    92 	RArray<TLogFileInfo> iFileList;
       
    93 
       
    94 	RFile* iFile;
       
    95 
       
    96 	HBufC8* iLogBuffer;
       
    97 	
       
    98 	TBool iDefaultLogFileInUse;
       
    99 	};
       
   100 
       
   101 #endif // __CIMAPLOGGER_H__