|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: TPresence Cache trace implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "presencetrace.h" |
|
20 |
|
21 #include <e32svr.h> |
|
22 #include <e32std.h> |
|
23 #include <flogger.h> |
|
24 |
|
25 |
|
26 /** |
|
27 * Handler used by trace implementation to truncate |
|
28 * the string rather than panic in case of buffer overflow. |
|
29 * |
|
30 * @since 3.0 |
|
31 */ |
|
32 NONSHARABLE_CLASS( TPresenceOverflowTruncate ) : public TDes16Overflow |
|
33 { |
|
34 public: |
|
35 void Overflow( TDes16& /*aDes*/ ) {} |
|
36 }; |
|
37 |
|
38 |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // PresenceTrace::Trace() |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C void PresenceTrace::Trace( TRefByValue<const TDesC> aFmt,... ) |
|
47 { |
|
48 TBuf< 250 > buffer; |
|
49 buffer.Append( _L("[") ); |
|
50 buffer.Append( RThread().Name() ); |
|
51 buffer.Append( _L("] ") ); |
|
52 |
|
53 TPresenceOverflowTruncate overflowHandler; |
|
54 |
|
55 VA_LIST list; |
|
56 VA_START( list, aFmt ); |
|
57 buffer.AppendFormatList( aFmt, list, &overflowHandler ); |
|
58 |
|
59 |
|
60 // #ifdef __WINS__ |
|
61 RDebug::Print( _L("%S"), &buffer ); |
|
62 // #endif // __WINS__ Pia |
|
63 // Pia #else |
|
64 |
|
65 RFileLogger logger; |
|
66 if( logger.Connect() == KErrNone ) |
|
67 { |
|
68 logger.SetDateAndTime( EFalse, ETrue ); |
|
69 logger.CreateLog( KPresenceTraceLogDir, |
|
70 KPresenceTraceLogFile, |
|
71 EFileLoggingModeAppend ); |
|
72 |
|
73 logger.Write( buffer ); |
|
74 logger.CloseLog(); |
|
75 logger.Close(); |
|
76 } |
|
77 |
|
78 // Pia #endif // __WINS__ |
|
79 } |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 // ============================ MEMBER FUNCTIONS =============================== |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // TPresenceBlockTraceHandler::TPresenceBlockTraceHandler() |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C TPresenceBlockTraceHandler::TPresenceBlockTraceHandler( const TText* aBlockName ) |
|
91 : iBlockName( aBlockName ), |
|
92 iBlockNormalExit( EFalse ) |
|
93 { |
|
94 TRACE_1( _L("%S - enter"), &iBlockName ); |
|
95 } |
|
96 |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // TPresenceBlockTraceHandler::~TPresenceBlockTraceHandler() |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C TPresenceBlockTraceHandler::~TPresenceBlockTraceHandler() // CSI: 82 # |
|
103 { |
|
104 if( !iBlockNormalExit ) |
|
105 { |
|
106 //Normal exit not recorded so far |
|
107 //Thus report here nonlocal exit |
|
108 TRACE_1( _L("%S - nonlocal exit"), &iBlockName ); |
|
109 } |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // TPresenceBlockTraceHandler::NormalExit() |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C void TPresenceBlockTraceHandler::NormalExit() |
|
118 { |
|
119 TRACE_1( _L("%S - exit"), &iBlockName ); |
|
120 iBlockNormalExit = ETrue; |
|
121 } |
|
122 |
|
123 |