|
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 // node message logging |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #include <elements/nm_log.h> |
|
24 #include <elements/nm_address.h> |
|
25 #include <elements/nm_signals.h> |
|
26 |
|
27 |
|
28 namespace Messages |
|
29 { |
|
30 |
|
31 EXPORT_C void Logging::Printf(const TDesC8& aSubTag, TRefByValue<const TDesC8> aFmt, ...) |
|
32 { |
|
33 VA_LIST list; |
|
34 VA_START(list,aFmt); |
|
35 Printf(aSubTag, Logging::ELogInfo, aFmt, list); |
|
36 VA_END(list); |
|
37 } |
|
38 |
|
39 |
|
40 EXPORT_C void Logging::Printf(const TDesC8& aSubTag, TRefByValue<const TDesC8> aFmt, VA_LIST& aList) |
|
41 { |
|
42 Printf(aSubTag, Logging::ELogInfo, aFmt, aList); |
|
43 } |
|
44 |
|
45 |
|
46 EXPORT_C void Logging::Printf(const TDesC8& aSubTag, TLogEntryType aType, TRefByValue<const TDesC8> aFmt, ...) |
|
47 { |
|
48 VA_LIST list; |
|
49 VA_START(list,aFmt); |
|
50 Printf(aSubTag, aType, aFmt, list); |
|
51 VA_END(list); |
|
52 } |
|
53 |
|
54 |
|
55 EXPORT_C void Logging::Printf(const TDesC8& /*aSubTag*/, TLogEntryType aType, TRefByValue<const TDesC8> aFmt, VA_LIST& aList) |
|
56 { |
|
57 TLogTextBuf buf; |
|
58 buf.AppendFormatIgnoreOverflow(aFmt, aList); |
|
59 UTracePfAny(KPrimaryFilter, aType, ETrue, EFalse, buf.Length(), buf.Ptr(), buf.Length()); |
|
60 } |
|
61 |
|
62 |
|
63 EXPORT_C void Logging::LogAddress(const TDesC8& /*aSubTag*/, const TRuntimeCtxId& aAddress, const TDesC8& aText) |
|
64 { |
|
65 TBuf8<KMaxLogTextLength + TRuntimeCtxId::KMaxInlineAddressSize> buf; |
|
66 if (aText.Length() > 0) |
|
67 { |
|
68 TPtrC8 subStr(aText.Ptr(), aText.Length() > KMaxLogTextLength ? KMaxLogTextLength : aText.Length()); |
|
69 buf.Copy(subStr); |
|
70 } |
|
71 buf.Append(reinterpret_cast<const TUint8*>(&aAddress), aAddress.Size()); |
|
72 |
|
73 |
|
74 UTracePfAny(KPrimaryFilter, Logging::ELogAddress, ETrue, EFalse, aText.Length(), buf.Ptr(), buf.Length()); |
|
75 } |
|
76 |
|
77 |
|
78 EXPORT_C void Logging::LogAddress(const TDesC8& aSubTag, const TRuntimeCtxId& aAddress) |
|
79 { |
|
80 LogAddress(aSubTag, aAddress, KNullDesC8); |
|
81 } |
|
82 |
|
83 |
|
84 EXPORT_C void Logging::LogMessage(const TDesC8& /*aSubTag*/, const TDesC8& aMessage, const TDesC8& aText) |
|
85 { |
|
86 if (aText.Length() > 0) |
|
87 { |
|
88 // Putting all the logging data into one event keeps them tied together |
|
89 // making the utrace decoders life easier and saves us from having to |
|
90 // use additional logging statements to group the message and text |
|
91 TBuf8<KMaxLogTextLength + TSignalBase::KMaxInlineMessageSize> buf; |
|
92 TPtrC8 subStr(aText.Ptr(), aText.Length() > KMaxLogTextLength ? KMaxLogTextLength : aText.Length()); |
|
93 buf.Copy(subStr); |
|
94 buf.Append(aMessage.Ptr(), aMessage.Length()); |
|
95 UTracePfAny(KPrimaryFilter, Logging::ELogMessage, ETrue, EFalse, subStr.Length(), buf.Ptr(), buf.Length()); |
|
96 } |
|
97 else |
|
98 { |
|
99 // Log only the message |
|
100 UTracePfAny(KPrimaryFilter, Logging::ELogMessage, ETrue, EFalse, 0, aMessage.Ptr(), aMessage.Length()); |
|
101 } |
|
102 } |
|
103 |
|
104 |
|
105 EXPORT_C void Logging::LogMessage(const TDesC8& aSubTag, const TDesC8& aMessage) |
|
106 { |
|
107 LogMessage(aSubTag, aMessage, KNullDesC8); |
|
108 } |
|
109 |
|
110 |
|
111 EXPORT_C void Logging::LogMessage(const TDesC8& /*aSubTag*/, const TSignalBase& aMessage, const TDesC8& aText) |
|
112 { |
|
113 TBuf8<KMaxLogTextLength + TSignalBase::KMaxInlineMessageSize> buf; |
|
114 TPtrC8 subStr(aText.Ptr(), aText.Length() > KMaxLogTextLength ? KMaxLogTextLength : aText.Length()); |
|
115 buf.Copy(subStr); |
|
116 |
|
117 TPtr8 messageBuf(const_cast<TUint8*>(buf.Ptr() + buf.Length()), buf.MaxLength() - buf.Length()); |
|
118 aMessage.Store(messageBuf); |
|
119 buf.SetLength(buf.Length() + messageBuf.Length()); |
|
120 UTracePfAny(KPrimaryFilter, Logging::ELogMessage, ETrue, EFalse, subStr.Length(), buf.Ptr(), buf.Length()); |
|
121 } |
|
122 |
|
123 |
|
124 EXPORT_C void Logging::LogMessage(const TDesC8& aSubTag, const TSignalBase& aMessage) |
|
125 { |
|
126 LogMessage(aSubTag, aMessage, KNullDesC8); |
|
127 } |
|
128 |
|
129 |
|
130 EXPORT_C void Logging::LogNode(const TDesC8& aSubTag, const ANode& aNode) |
|
131 { |
|
132 LogNode(aSubTag, aNode, KNullDesC8); |
|
133 } |
|
134 |
|
135 |
|
136 EXPORT_C void Logging::LogNode(const TDesC8& /*aSubTag*/, const ANode& aNode, const TDesC8& aText) |
|
137 { |
|
138 TBuf8<KMaxLogTextLength + sizeof(ANode*)> buf; |
|
139 TPtrC8 subStr(aText.Ptr(), aText.Length() > KMaxLogTextLength ? KMaxLogTextLength : aText.Length()); |
|
140 buf.Copy(subStr); |
|
141 const ANode* ptr = &aNode; |
|
142 TPckgC<const ANode*> pckg(ptr); |
|
143 buf.Append(pckg); |
|
144 UTracePfAny(KPrimaryFilter, Logging::ELogNode, ETrue, EFalse, subStr.Length(), buf.Ptr(), buf.Length()); |
|
145 } |
|
146 |
|
147 } |
|
148 // namespace Messages |
|
149 |
|
150 |