Symbian3/PDK/Source/GUID-2022F702-9899-5798-8932-D70119C7177D.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Tue, 30 Mar 2010 11:56:28 +0100
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 9 59758314f811
permissions -rw-r--r--
Week 12 contribution of PDK documentation_content. See release notes for details. Fixes Bug 2054, Bug 1583, Bug 381, Bug 390, Bug 463, Bug 1897, Bug 344, Bug 1319, Bug 394, Bug 1520, Bug 1522, Bug 1892"

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-2022F702-9899-5798-8932-D70119C7177D" xml:lang="en"><title>Setting
Up A Log Engine Client </title><shortdesc>This tutorial describes how to set up a Log Engine client. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-4EAACF43-7B17-522C-A617-96C15971EBCA"><title>Introduction</title> <p>If
you are certain that you are coding for a platform with logging functionality
you create a custom class with some such name as <xref href="GUID-3016DE27-6C94-3119-B174-831B67B09B27.dita"><apiname>CMyLogEngine</apiname></xref>.
It should have members of the classes <xref href="GUID-51C67545-12BA-326D-BD8F-662B24C68ED2.dita"><apiname>CLogClient</apiname></xref>, <xref href="GUID-3A3E6F09-0F78-38E1-95F5-00C743F41073.dita"><apiname>CLogViewEvent</apiname></xref>, <xref href="GUID-F40F9556-F223-36A5-9812-6EF6FF3F5156.dita"><apiname>CLogViewRecent</apiname></xref> and <xref href="GUID-99144BA6-F79A-3D3C-B1D3-272B3723C42C.dita"><apiname>CLogFilter</apiname></xref> and an observer of some kind. The functions of your
custom class will use the functionality of these classes by calls to the member
objects. </p> <p>If you are not certain that your platform will provide logging
functionality you must use a log wrapper framework. Write a custom class to
use the log wrapper functionality with some such name as <codeph>myLogWrapper</codeph>.
It should have two members which own <xref href="GUID-146D719E-BDD6-3F20-80B1-EDE09081A6EA.dita"><apiname>CLogWrapper</apiname></xref> and <xref href="GUID-51C67545-12BA-326D-BD8F-662B24C68ED2.dita"><apiname>CLogClient</apiname></xref> objects.
In the constructor function of <codeph>myLogWrapper</codeph> call the <xref href="GUID-51862DAE-2285-352F-B66E-B2544638E30E.dita"><apiname>ClientAvailable()</apiname></xref> function
of <xref href="GUID-146D719E-BDD6-3F20-80B1-EDE09081A6EA.dita"><apiname>CLogWrapper</apiname></xref> to determine whether logging functionality
is present. If so, construct the <xref href="GUID-51C67545-12BA-326D-BD8F-662B24C68ED2.dita"><apiname>CLogClient</apiname></xref> member: if
not, leave. The effect of this is that calls to the log client functionality
of <codeph>myLogWrapper</codeph> will access an actual log client if the functionality
is available. However, if the functionality is not available calls to the
log client functionality will either have no effect or else leave as in this
example code. </p> </section>
<section id="GUID-00974547-A3DC-442C-B50C-1C8E7180B8A4"><title>Procedure</title> <ol id="GUID-F8F83C3B-A722-5C79-B286-F48F51019524">
<li id="GUID-7F2D3FBF-E541-530D-9A56-3C49A1D006E2"><p>Create a custom class <xref href="GUID-3016DE27-6C94-3119-B174-831B67B09B27.dita"><apiname>CMyLogEngine</apiname></xref>  </p> </li>
<li id="GUID-DFCDEC1F-3B62-5A65-97DB-E63DC68BFEED"><p>Declare the members <xref href="GUID-51C67545-12BA-326D-BD8F-662B24C68ED2.dita"><apiname>CLogClient</apiname></xref>, <xref href="GUID-3A3E6F09-0F78-38E1-95F5-00C743F41073.dita"><apiname>CLogViewEvent</apiname></xref>, <xref href="GUID-F40F9556-F223-36A5-9812-6EF6FF3F5156.dita"><apiname>CLogViewRecent</apiname></xref> and <xref href="GUID-99144BA6-F79A-3D3C-B1D3-272B3723C42C.dita"><apiname>CLogFilter</apiname></xref> in the header
file of the client application </p> </li>
<li id="GUID-3471D668-8369-5458-B436-FD8344988065"><p>Declare <xref href="GUID-BD2669C7-AE36-3AA8-AAAE-A2F01A319369.dita"><apiname>ConstrucL()</apiname></xref> function
in the header file of the client application </p> </li>
<li id="GUID-5B55236A-F7C8-54FB-B0E9-D3CAC99ADDF0"><p>Implement <xref href="GUID-C8E0575D-5A7F-3D00-9BE5-AD8D6DBCF2F7.dita"><apiname>ConstructL()</apiname></xref> function </p> <ol id="GUID-B6FFC684-372C-5FC3-9035-B7A0FF4B884E">
<li id="GUID-8FAB2EEA-79D9-5572-B2F2-15057B860366"><p>Establish a connection
to the Log Engine </p> <p><codeblock id="GUID-CDFA500C-FB18-5713-B4F9-7D355D107122" xml:space="preserve">    iLogClient = CLogClient::NewL(iFs);</codeblock> </p> </li>
<li id="GUID-E8DFFAD0-506E-5752-B51D-52153AEADD37"><p>get the log events using <codeph>CLogViewEvent</codeph>  </p> <p><codeblock id="GUID-55F3DE8A-FAC5-5C9F-8931-55CA7838A8F2" xml:space="preserve">iLogViewEvent = CLogViewEvent::NewL(*iLogClient);</codeblock> </p> </li>
<li id="GUID-7CF80109-CA54-549F-A46D-3C950DAC1711"><p>get the log of recent
events using <xref href="GUID-F40F9556-F223-36A5-9812-6EF6FF3F5156.dita"><apiname>CLogViewRecent</apiname></xref>  </p> <p><codeblock id="GUID-3406E92A-432B-57E6-B6A2-3D63C4EC0B72" xml:space="preserve">iLogViewRecent = CLogViewRecent::NewL(*iLogClient);</codeblock> </p> </li>
<li id="GUID-F9DB43F5-F69D-50D1-B287-EFC85DA9828E"><p>add a log filter using <xref href="GUID-F7EB6F45-0FBE-39E7-B146-8E500356B5BE.dita"><apiname>ClogFilter</apiname></xref>  </p> <p><codeblock id="GUID-F90E0B70-AC53-54B9-93B4-26B33A919B33" xml:space="preserve">iLogFilter = CLogFilter::NewL();</codeblock> </p> </li>
</ol> </li>
</ol> </section>
<section id="GUID-BE0D8C52-2FCA-45F2-9BEF-42D5F8CCD4F9"><title>Result</title> <p>The client applications can use the log
events to be displayed to the user or for other used as a data for further
processing. </p> </section>
<example id="GUID-22EAC40F-881C-5AC0-B919-016E502CC7E6"><title>Log engine
client example</title> <p>Example code for a Log Engine client on a platform
with logging functionality </p> <codeblock id="GUID-2C393B78-BAA0-5893-9A6A-9DC9D76749B6" xml:space="preserve">void CMyLogEngine::ConstructL()
    {
    
    // Establish connection to log engine
    iLogClient = CLogClient::NewL(iFs);
 
    // Log view and view for recent events with standard priority
    iLogViewEvent = CLogViewEvent::NewL(*iLogClient);
    iLogViewRecent = CLogViewRecent::NewL(*iLogClient);

    // Filter for events
    iLogFilter = CLogFilter::NewL();
</codeblock> <p>Example code for a Log Engine client using a wrapper framework </p> <codeblock id="GUID-A409E255-3B0B-51C9-9633-010608E07122" xml:space="preserve">void CMyLogWrapper::ConstructL(RFs&amp; aFs)
     {
     
     // create the CLogWrapper to forward requests to.
     iLogWrapper = CLogWrapper::NewL(aFs);
 
     if (iLogWrapper-&gt;ClientAvailable())
         {
         iLogClient = static_cast&lt;CLogClient*&gt;(&amp;iLogWrapper-&gt;Log());
         }
     else
         {
         User::Leave(KErrNotSupported);
         }
     }

</codeblock> <p>You can now use <codeph>myLogWrapper</codeph> as if it was
a log client. </p> </example>
</conbody><related-links>
<link href="GUID-E4A950EA-5671-5755-B3EF-5D6B90E19AE6.dita"><linktext>Maintaining
Log Events</linktext></link>
<link href="GUID-BE65B3A7-04E8-5406-B46A-09E2608E0F1F.dita"><linktext>Requesting
Log Engine Notifications</linktext></link>
<link href="GUID-55ECBCF5-FC29-5A4A-A3C6-1CB1C0D562CE.dita"><linktext>Displaying
Log Events</linktext></link>
<link href="GUID-BCB0E50F-B22E-5964-BB68-BEE1870D9C79.dita"><linktext>Configuring
Log Engine </linktext></link>
</related-links></concept>