appfw/viewserver/inc/VWSDEBUG.H
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 1999-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 __VWSDEBUG_H__
       
    17 #define __VWSDEBUG_H__
       
    18 
       
    19 #include <e32svr.h>
       
    20 #include <f32file.h>
       
    21 
       
    22 #ifdef _DEBUG
       
    23 #define __DO_LOGGING__
       
    24 #endif
       
    25 
       
    26 #ifndef __DO_LOGGING__
       
    27 
       
    28 #define LOG1(_p1)
       
    29 #define LOG2(_p1,_p2)
       
    30 #define LOG3(_p1,_p2,_p3)
       
    31 #define LOG4(_p1,_p2,_p3,_p4)
       
    32 #define LOG5(_p1,_p2,_p3,_p4,_p5)
       
    33 #define LOG6(_p1,_p2,_p3,_p4,_p5,_p6)
       
    34 #define LOG7(_p1,_p2,_p3,_p4,_p5,_p6,_p7)
       
    35 #define LOG8(_p1,_p2,_p3,_p4,_p5,_p6,_p7,_p8)
       
    36 
       
    37 #else
       
    38 
       
    39 #define LOG1(_p1) CVwsLog::Log(_p1)
       
    40 #define LOG2(_p1,_p2) CVwsLog::Log(_p1,_p2)
       
    41 #define LOG3(_p1,_p2,_p3) CVwsLog::Log(_p1,_p2,_p3)
       
    42 #define LOG4(_p1,_p2,_p3,_p4) CVwsLog::Log(_p1,_p2,_p3,_p4)
       
    43 #define LOG5(_p1,_p2,_p3,_p4,_p5) CVwsLog::Log(_p1,_p2,_p3,_p4,_p5)
       
    44 #define LOG6(_p1,_p2,_p3,_p4,_p5,_p6) CVwsLog::Log(_p1,_p2,_p3,_p4,_p5,_p6)
       
    45 #define LOG7(_p1,_p2,_p3,_p4,_p5,_p6,_p7) CVwsLog::Log(_p1,_p2,_p3,_p4,_p5,_p6,_p7)
       
    46 #define LOG8(_p1,_p2,_p3,_p4,_p5,_p6,_p7,_p8) CVwsLog::Log(_p1,_p2,_p3,_p4,_p5,_p6,_p7,_p8)
       
    47 
       
    48 
       
    49 /**
       
    50  * The CVwsLog class implements debug logging for the view server.
       
    51  */ 
       
    52 NONSHARABLE_CLASS(CVwsLog) : public CBase
       
    53 	{
       
    54 public:
       
    55 	enum TLogType
       
    56 		{
       
    57 		EFile,
       
    58 		ERDebug,
       
    59 		EBoth,
       
    60 		ENeither
       
    61 		};
       
    62 	enum TLevel
       
    63 		{
       
    64 		ESpecial,
       
    65 		EQuiet,
       
    66 		ENormal,
       
    67 		ELoud,
       
    68 		EShouting
       
    69 		};
       
    70 public:
       
    71 	static void StartLogL();
       
    72 	static void ShutdownLog();
       
    73 	static void Log(TLevel aLogLevel,TRefByValue<const TDesC> aFmt,...);
       
    74 	void SetLevel(TLevel aLogLevel);
       
    75 	void SetType(TLogType aType);
       
    76 private:
       
    77 	CVwsLog();
       
    78 	~CVwsLog();
       
    79 	void ConstructL();
       
    80 	void DoLog(TLevel aLogLevel,const TDesC& aOutput);
       
    81 	void LogToFile(TLevel aLogLevel,const TDesC& aOutput);
       
    82 	void LogToRDebug(const TDesC& aOutput);
       
    83 private:
       
    84 	RFs iFs;
       
    85 	RFile iLogFile;
       
    86 	TLogType iType;
       
    87 	TBool iActive;
       
    88 	TLevel iLevel;
       
    89 	TPtrC8 iEol;
       
    90 	TBuf16<2> iEol16;
       
    91 	};
       
    92 
       
    93 #endif
       
    94 #endif