|
1 // wsp_log.cpp |
|
2 // |
|
3 // Copyright (c) 2004 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include "wsp_log.h" |
|
14 |
|
15 #ifdef WSP_LOGGING |
|
16 |
|
17 #include <comms-infras/commsdebugutility.h> |
|
18 |
|
19 _LIT8(KSubSystem, "fshell"); |
|
20 _LIT8(KComponent, "winsockprt"); |
|
21 |
|
22 |
|
23 RFileLogger& Logger() |
|
24 { |
|
25 return *(static_cast<RFileLogger*>(Dll::Tls())); |
|
26 } |
|
27 |
|
28 TInt WspLog::Open() |
|
29 { |
|
30 RFileLogger* logger = new RFileLogger(); |
|
31 if (logger == NULL) |
|
32 { |
|
33 return KErrNoMemory; |
|
34 } |
|
35 |
|
36 TInt err = logger->Connect(); |
|
37 if (err == KErrNone) |
|
38 { |
|
39 err = logger->SetLogTags(KSubSystem(), KComponent()); |
|
40 if (err == KErrNone) |
|
41 { |
|
42 Dll::SetTls(logger); |
|
43 } |
|
44 } |
|
45 |
|
46 return err; |
|
47 } |
|
48 |
|
49 void WspLog::Close() |
|
50 { |
|
51 RFileLogger* logger = &(Logger()); |
|
52 logger->Close(); |
|
53 delete logger; |
|
54 Dll::SetTls(NULL); |
|
55 } |
|
56 |
|
57 void WspLog::Write(const TDesC& aDes) |
|
58 { |
|
59 Logger().Write(aDes); |
|
60 } |
|
61 |
|
62 void WspLog::Printf(TRefByValue<const TDesC> aFmt, ...) |
|
63 { |
|
64 VA_LIST list; |
|
65 VA_START(list, aFmt); |
|
66 Logger().WriteFormat(aFmt, list); |
|
67 } |
|
68 |
|
69 void WspLog::Printf(TRefByValue<const TDesC8> aFmt, ...) |
|
70 { |
|
71 VA_LIST list; |
|
72 VA_START(list, aFmt); |
|
73 Logger().WriteFormat(aFmt, list); |
|
74 } |
|
75 |
|
76 void WspLog::HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen) |
|
77 { |
|
78 Logger().HexDump(aHeader, aMargin, aPtr, aLen); |
|
79 } |
|
80 |
|
81 void WspLog::WriteRawInbound(const TDesC8& aDes) |
|
82 { |
|
83 Logger().Write(_L("In-bound data:")); |
|
84 Logger().HexDump(aDes); |
|
85 } |
|
86 |
|
87 void WspLog::WriteRawOutbound(const TDesC8& aDes) |
|
88 { |
|
89 Logger().Write(_L("Out-bound data:")); |
|
90 Logger().HexDump(aDes); |
|
91 } |
|
92 |
|
93 |
|
94 #endif // _DEBUG |