|
1 // Copyright (c) 2007-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 // mesh machine logging |
|
15 // Note: some of these log outputs are used by SVG tools - careful when changing them |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 */ |
|
23 |
|
24 #include "mm_log.h" |
|
25 #include <elements/mm_context.h> |
|
26 #include <elements/mm_activities.h> |
|
27 |
|
28 using namespace Messages; |
|
29 namespace MeshMachine |
|
30 { |
|
31 EXPORT_C void Logging::Printf(const TDesC8& aSubTag, TRefByValue<const TDesC8> aFmt, ...) |
|
32 { |
|
33 #ifdef SYMBIAN_TRACE_ENABLE |
|
34 VA_LIST list; |
|
35 VA_START(list,aFmt); |
|
36 Printf(aSubTag, aFmt, list); |
|
37 VA_END(list); |
|
38 #else |
|
39 (void)aSubTag; |
|
40 (void)aFmt; |
|
41 #endif |
|
42 } |
|
43 |
|
44 |
|
45 EXPORT_C void Logging::Printf(const TDesC8& /*aSubTag*/, TRefByValue<const TDesC8> aFmt, VA_LIST& aList) |
|
46 { |
|
47 #ifdef SYMBIAN_TRACE_ENABLE |
|
48 TLogTextBuf buf; |
|
49 buf.AppendFormatIgnoreOverflow(aFmt, aList); |
|
50 UTracePfAny(KPrimaryFilter, MeshMachine::Logging::ELogInfo, ETrue, EFalse, buf.Length(), buf.Ptr(), buf.Length()); |
|
51 #else |
|
52 //(void)aSubTag; |
|
53 (void)aFmt; |
|
54 (void)aList; |
|
55 #endif |
|
56 } |
|
57 |
|
58 |
|
59 EXPORT_C void Logging::LogContext(const TDesC8& aSubTag, const TNodeContextBase& aContext) |
|
60 { |
|
61 #ifdef SYMBIAN_TRACE_ENABLE |
|
62 LogContext(aSubTag, aContext, KNullDesC8); |
|
63 #else |
|
64 (void)aSubTag; |
|
65 (void)aContext; |
|
66 #endif |
|
67 } |
|
68 |
|
69 |
|
70 EXPORT_C void Logging::LogContext(const TDesC8& aSubTag, const TNodeContextBase& aContext, const TDesC8& aText) |
|
71 { |
|
72 #ifdef SYMBIAN_TRACE_ENABLE |
|
73 NM_LOG_START_BLOCK(aSubTag, _L8("Ctx")); |
|
74 if (aText.Length() > 0) |
|
75 { |
|
76 Printf(aSubTag, aText); |
|
77 } |
|
78 NM_LOG_NODE_EXT(aSubTag, aContext.NodeId().Node(), KNullDesC8); |
|
79 NM_LOG_ADDRESS_EXT(aSubTag, aContext.iSender, _L8("From:")); |
|
80 NM_LOG_ADDRESS_EXT(aSubTag, aContext.iRecipient, _L8("To:")); |
|
81 LogActivity(aSubTag, aContext.iNodeActivity, NULL); |
|
82 NM_LOG_END_BLOCK(aSubTag, KNullDesC8); |
|
83 #else |
|
84 (void)aSubTag; |
|
85 (void)aContext; |
|
86 (void)aText; |
|
87 #endif |
|
88 } |
|
89 |
|
90 |
|
91 EXPORT_C void Logging::LogActivity(const TDesC8& aSubTag, const CNodeActivityBase* aActivity, const TNodeContextBase* aContext) |
|
92 { |
|
93 LogActivity(aSubTag, aActivity, aContext, KNullDesC8); |
|
94 } |
|
95 |
|
96 |
|
97 EXPORT_C void Logging::LogActivity(const TDesC8& aSubTag, const CNodeActivityBase* aActivity, const TNodeContextBase* aContext, const TDesC8& aText) |
|
98 { |
|
99 #ifdef SYMBIAN_TRACE_ENABLE |
|
100 const ANode* node = NULL; |
|
101 if (aContext) |
|
102 { |
|
103 node = &aContext->NodeId().Node(); |
|
104 } |
|
105 |
|
106 if (aActivity) |
|
107 { |
|
108 if (node) |
|
109 { |
|
110 Printf(aSubTag, _L8("%S [ANode=0x%08x] [Activity=%s] [Triple=%s]"), &aText, node, aActivity->ActivityName(), aActivity->CurrentTripleName()); |
|
111 } |
|
112 else |
|
113 { |
|
114 Printf(aSubTag, _L8("%S [Activity=%s] [Triple=%s]"), &aText, aActivity->ActivityName(), aActivity->CurrentTripleName()); |
|
115 } |
|
116 } |
|
117 else |
|
118 if (aText.Length()) |
|
119 { |
|
120 Printf(aSubTag, _L8("%S "), &aText); |
|
121 } |
|
122 #else |
|
123 (void)aSubTag; |
|
124 (void)aActivity; |
|
125 (void)aContext; |
|
126 (void)aText; |
|
127 #endif |
|
128 } |
|
129 |
|
130 } //MeshMachine |
|
131 |
|
132 |