|
1 // Copyright (c) 2001-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 // |
|
15 |
|
16 #include <e32base.h> |
|
17 #include <e32svr.h> |
|
18 #include "StringPoolImplementation.h" |
|
19 |
|
20 //#define BAFL_SHOW_TRACE |
|
21 |
|
22 #ifdef BAFL_SHOW_TRACE |
|
23 void BaflShowTrace(TRefByValue<const TDesC> aFmt,...) |
|
24 { |
|
25 RDebug::Print(aFmt); |
|
26 } |
|
27 #else |
|
28 void BaflShowTrace(TRefByValue<const TDesC> /*aFmt*/,...) |
|
29 { |
|
30 } |
|
31 #endif |
|
32 |
|
33 #ifdef _DEBUG |
|
34 |
|
35 _LIT8(KLogPrefix, "StringPool: "); |
|
36 _LIT8(KTooLong, "(Value Too Long to print)"); |
|
37 |
|
38 NONSHARABLE_CLASS(TStringLogOverflow) : public TDes8Overflow |
|
39 { |
|
40 public: |
|
41 virtual void Overflow(TDes8& aDes); |
|
42 }; |
|
43 |
|
44 void TStringLogOverflow::Overflow(TDes8& /* aDes*/) |
|
45 { |
|
46 } |
|
47 |
|
48 void StringUtils::LogIt(TRefByValue<const TDesC8> aFmt, ...) |
|
49 // |
|
50 // Messages to the front end emulator and to the WAP log |
|
51 { |
|
52 VA_LIST list; |
|
53 VA_START(list,aFmt); |
|
54 |
|
55 _LIT8(KLogPrefix, "StringPool: "); |
|
56 |
|
57 TStringLogOverflow overflow; |
|
58 |
|
59 TBuf8<KMaxFileName - 1> buf; |
|
60 buf.Copy(KLogPrefix); |
|
61 buf.AppendFormatList(aFmt, list, &overflow); |
|
62 VA_END(list); |
|
63 |
|
64 TBuf<KMaxFileName> buf16; |
|
65 buf16.Copy(buf); |
|
66 BaflShowTrace(buf16); |
|
67 BaflShowTrace(_L("\n")); |
|
68 } |
|
69 void StringUtils::LogIt1(TRefByValue<const TDesC8> aFmt) |
|
70 // |
|
71 // Messages to the front end emulator and to the WAP log |
|
72 { |
|
73 const TDesC8& format = aFmt; |
|
74 |
|
75 TBuf8<KMaxFileName - 1> buf; |
|
76 buf.Copy(KLogPrefix); |
|
77 if (buf.Length() + format.Length() > KMaxFileName - 1) |
|
78 buf.Append(KTooLong); |
|
79 else |
|
80 buf.Append(aFmt); |
|
81 |
|
82 TBuf<KMaxFileName> buf16; |
|
83 buf16.Copy(buf); |
|
84 BaflShowTrace(_L("%S"), &buf16); |
|
85 BaflShowTrace(_L("\n")); |
|
86 } |
|
87 |
|
88 #endif // _DEBUG |