7 Nokia Corporation - initial contribution. |
7 Nokia Corporation - initial contribution. |
8 Contributors: |
8 Contributors: |
9 --> |
9 --> |
10 <!DOCTYPE concept |
10 <!DOCTYPE concept |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
12 <concept xml:lang="en" id="GUID-2022F702-9899-5798-8932-D70119C7177D"><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><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><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() |
12 <concept id="GUID-2022F702-9899-5798-8932-D70119C7177D" xml:lang="en"><title>Setting |
|
13 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> |
|
14 <section id="GUID-4EAACF43-7B17-522C-A617-96C15971EBCA"><title>Introduction</title> <p>If |
|
15 you are certain that you are coding for a platform with logging functionality |
|
16 you create a custom class with some such name as <xref href="GUID-3016DE27-6C94-3119-B174-831B67B09B27.dita"><apiname>CMyLogEngine</apiname></xref>. |
|
17 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 |
|
18 custom class will use the functionality of these classes by calls to the member |
|
19 objects. </p> <p>If you are not certain that your platform will provide logging |
|
20 functionality you must use a log wrapper framework. Write a custom class to |
|
21 use the log wrapper functionality with some such name as <codeph>myLogWrapper</codeph>. |
|
22 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. |
|
23 In the constructor function of <codeph>myLogWrapper</codeph> call the <xref href="GUID-51862DAE-2285-352F-B66E-B2544638E30E.dita"><apiname>ClientAvailable()</apiname></xref> function |
|
24 of <xref href="GUID-146D719E-BDD6-3F20-80B1-EDE09081A6EA.dita"><apiname>CLogWrapper</apiname></xref> to determine whether logging functionality |
|
25 is present. If so, construct the <xref href="GUID-51C67545-12BA-326D-BD8F-662B24C68ED2.dita"><apiname>CLogClient</apiname></xref> member: if |
|
26 not, leave. The effect of this is that calls to the log client functionality |
|
27 of <codeph>myLogWrapper</codeph> will access an actual log client if the functionality |
|
28 is available. However, if the functionality is not available calls to the |
|
29 log client functionality will either have no effect or else leave as in this |
|
30 example code. </p> </section> |
|
31 <section id="GUID-00974547-A3DC-442C-B50C-1C8E7180B8A4"><title>Procedure</title> <ol id="GUID-F8F83C3B-A722-5C79-B286-F48F51019524"> |
|
32 <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> |
|
33 <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 |
|
34 file of the client application </p> </li> |
|
35 <li id="GUID-3471D668-8369-5458-B436-FD8344988065"><p>Declare <xref href="GUID-BD2669C7-AE36-3AA8-AAAE-A2F01A319369.dita"><apiname>ConstrucL()</apiname></xref> function |
|
36 in the header file of the client application </p> </li> |
|
37 <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"> |
|
38 <li id="GUID-8FAB2EEA-79D9-5572-B2F2-15057B860366"><p>Establish a connection |
|
39 to the Log Engine </p> <p><codeblock id="GUID-CDFA500C-FB18-5713-B4F9-7D355D107122" xml:space="preserve"> iLogClient = CLogClient::NewL(iFs);</codeblock> </p> </li> |
|
40 <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> |
|
41 <li id="GUID-7CF80109-CA54-549F-A46D-3C950DAC1711"><p>get the log of recent |
|
42 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> |
|
43 <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> |
|
44 </ol> </li> |
|
45 </ol> </section> |
|
46 <section id="GUID-BE0D8C52-2FCA-45F2-9BEF-42D5F8CCD4F9"><title>Result</title> <p>The client applications can use the log |
|
47 events to be displayed to the user or for other used as a data for further |
|
48 processing. </p> </section> |
|
49 <example id="GUID-22EAC40F-881C-5AC0-B919-016E502CC7E6"><title>Log engine |
|
50 client example</title> <p>Example code for a Log Engine client on a platform |
|
51 with logging functionality </p> <codeblock id="GUID-2C393B78-BAA0-5893-9A6A-9DC9D76749B6" xml:space="preserve">void CMyLogEngine::ConstructL() |
13 { |
52 { |
14 |
53 |
15 // Establish connection to log engine |
54 // Establish connection to log engine |
16 iLogClient = CLogClient::NewL(iFs); |
55 iLogClient = CLogClient::NewL(iFs); |
17 |
56 |
18 // Log view and view for recent events events with standard priority |
57 // Log view and view for recent events with standard priority |
19 iLogViewEvent = CLogViewEvent::NewL(*iLogClient); |
58 iLogViewEvent = CLogViewEvent::NewL(*iLogClient); |
20 iLogViewRecent = CLogViewRecent::NewL(*iLogClient); |
59 iLogViewRecent = CLogViewRecent::NewL(*iLogClient); |
21 |
60 |
22 // Filter for events |
61 // Filter for events |
23 iLogFilter = CLogFilter::NewL(); |
62 iLogFilter = CLogFilter::NewL(); |
35 { |
74 { |
36 User::Leave(KErrNotSupported); |
75 User::Leave(KErrNotSupported); |
37 } |
76 } |
38 } |
77 } |
39 |
78 |
40 </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> |
79 </codeblock> <p>You can now use <codeph>myLogWrapper</codeph> as if it was |
|
80 a log client. </p> </example> |
|
81 </conbody><related-links> |
|
82 <link href="GUID-E4A950EA-5671-5755-B3EF-5D6B90E19AE6.dita"><linktext>Maintaining |
|
83 Log Events</linktext></link> |
|
84 <link href="GUID-BE65B3A7-04E8-5406-B46A-09E2608E0F1F.dita"><linktext>Requesting |
|
85 Log Engine Notifications</linktext></link> |
|
86 <link href="GUID-55ECBCF5-FC29-5A4A-A3C6-1CB1C0D562CE.dita"><linktext>Displaying |
|
87 Log Events</linktext></link> |
|
88 <link href="GUID-BCB0E50F-B22E-5964-BB68-BEE1870D9C79.dita"><linktext>Configuring |
|
89 Log Engine </linktext></link> |
|
90 </related-links></concept> |