os/persistentdata/traceservices/commsdebugutility/TE_commsdebugutility/src/designexample.cpp
Update contrib.
1 // Copyright (c) 2003-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Runs the example code provided in the design and how to docs with flogger.
18 #include <comms-infras/commsdebugutility.h>
21 const TInt KFloggerFileFlushTime = 1000000; //< Flogger flushes its file buffer every second
22 const TInt KFloggerIdleTimeWait = 1000000; //< A guess (!) at how long the system needs to be idle before flogger's lower-priority thread kicks in and writes the data.
23 const TInt KFloggerWriteTime = 500000; ///< Give flogger 1/2 second to write the data.
24 const TInt KTimeToLog = KFloggerFileFlushTime + KFloggerIdleTimeWait + KFloggerWriteTime; //< 2.5-second delay used to guarantee the logger will have written to the log file before reading the message.
25 _LIT(KTitle1,"You have run the Comsdbg DesignExample.\n");
26 _LIT(KTitle2,"Make sure commsdbg.ini contains the line:\n");
27 _LIT(KTitle3,"LOG XComm *\n\n");
30 _LIT(KError1,"Error: You have not built this with flogger enabled.\n");
33 _LIT(KProgress1,"Running foo()...\n");
34 _LIT(KProgress2,"Running X::SetInt(5)...\n");
35 _LIT(KProgress3,"Running X::GetInt...\n");
36 _LIT(KProgressDone,"All Done. Check c:\\logs\\log.txt for results.");
38 _LIT(KWindowTtl,"DesignExample");
39 const TInt KConsWidth=50;
40 const TInt KConsHeight=15;
41 //***** Start of example code from Design Specification *****//
43 __FLOG_STMT(_LIT8(KSubsys,"XComm");)
44 __FLOG_STMT(_LIT8(KComponent,"Sprocket");)
45 __FLOG_STMT(_LIT8(KTempSubsys,"NewXComm");) // Temporary subsystem name
46 __FLOG_STMT(_LIT8(KTempComponent,"NewSprocket");) // Temporary component name
53 inline X(const X& aRhs);
54 inline X& operator=(const X& aRhs);
57 inline void ChangeTag();
58 inline void RestoreTag();
60 inline TUint GetInt();
61 inline void SetInt(TUint aVal);
64 __FLOG_DECLARATION_MEMBER;
69 __FLOG_OPEN(KSubsys, KComponent);
72 X::X(const X& aRhs) : iInt(aRhs.iInt)
74 __FLOG_OPEN(KSubsys, KComponent);
77 X& X::operator=(const X& aRhs)
82 __FLOG_OPEN(KSubsys, KComponent);
89 __FLOG_SET_TAGS(KTempSubsys, KTempComponent);
90 __FLOG(_L8("Temporally changed the tags in the log file "));
91 // The tags are changed
96 __FLOG_SET_TAGS(KSubsys, KComponent);
97 __FLOG(_L8("Restored the original tags in the log file "));
98 // The tags are restored
110 _LIT(KHiThere,"hi there ");
111 _LIT8(KHiThere8,"hi there ");
112 _LIT8(KDumpPi," Pi = %d.%d%d%d%d%d%d%d%d");
113 _LIT8(KGetInt," X::GetInt() - about to return the integer: %d ");
116 //__FLOG("hi there"); //illegal - compile time error
117 __FLOG(KHiThere); //ok - but inefficient in a Unicode build
118 __FLOG(KHiThere8); //good!
119 __FLOG_0(KHiThere8); //exactly the same as the previous line
120 __FLOG_9(KDumpPi, 3, 1, 4, 1, 5, 9, 2, 6, 5);
122 __FLOG_1(KGetInt, iInt);
126 void X::SetInt(TUint aVal)
128 __FLOG_STMT(_LIT(KString, "X::SetInt - setting iInt to: ");)
131 __FLOG_STMT(_LIT8(KFormatForHex,"%2d");)
132 __FLOG_STMT(const TInt KMaxHexString = 3;)
133 __FLOG_STMT(TBuf8<KMaxHexString> buf;)
134 __FLOG_STMT(buf.Format(KFormatForHex,aVal);)
136 __FLOG_HEXDUMP (( buf ));
142 __FLOG_STMT(_LIT8(KFooSubsys,"XComm");)
143 __FLOG_STMT(_LIT8(KFooComponent,"Foo");)
144 __FLOG_STMT(_LIT8(KDemoString,"Logging test");)
148 __FLOG_DECLARATION_VARIABLE;
149 __FLOG_OPEN(KFooSubsys, KFooComponent);
150 __FLOG_VA (( KDemoString ));
154 //***** End of example code from Design Specification *****//
159 // Create a console for communication to user of progress
160 CConsoleBase *console=Console::NewL(KWindowTtl,TSize(KConsWidth,KConsHeight));
161 __FLOG_STMT(console->Printf(KTitle1);)
162 __FLOG_STMT(console->Printf(KTitle2);)
163 __FLOG_STMT(console->Printf(KTitle3);)
165 #ifndef __FLOG_ACTIVE
166 console->Printf(KError1);
169 __FLOG_STMT(console->Printf(KProgress1));
174 __FLOG_STMT(console->Printf(KProgress2);)
176 __FLOG_STMT(console->Printf(KProgress3);)
178 __FLOG_STMT(console->Printf(KProgressDone);)
180 __FLOG_STMT(User::After(KTimeToLog);)
181 __FLOG_STMT(User::After(KTimeToLog);)
185 GLDEF_C TInt E32Main()
187 TRAP_IGNORE(MainL());