|
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 the License "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: API for FileLogger.dll |
|
15 * |
|
16 */ |
|
17 // This file defines the API for FileLogger.dll |
|
18 #ifndef __FILELOGGER_H__ |
|
19 #define __FILELOGGER_H__ |
|
20 |
|
21 #include <f32file.h> |
|
22 const TInt KMaxLogEntrySize = 400; |
|
23 |
|
24 #ifdef GESTURE_LOGGING |
|
25 #if defined(__WINS__) && !defined(__SERIES60_30__) |
|
26 #define RDEBUG(args...) RDebug::Printf(args) |
|
27 #define RDEBUG8(args) RDebug::RawPrint(args) |
|
28 #define RDEBUG16(args...) RDebug::Print(args...) |
|
29 #else |
|
30 #define RDEBUG(args...) |
|
31 #define RDEBUG8(args) |
|
32 #define RDEBUG16(args...) |
|
33 #endif |
|
34 |
|
35 #define LOGFLUSH CFileLogger::Flush() |
|
36 #define LOGCLOSE CFileLogger::Close() |
|
37 #define LOGARG(txt,parm...) {_LIT8(KTxt, txt); CFileLogger::Write(KTxt, parm); RDEBUG(txt, parm);} |
|
38 #define LOGTXT(txt) {_LIT8(KTxt, txt); CFileLogger::Write((const TDesC8&)KTxt); RDEBUG8(KTxt);} |
|
39 #define LOGDES8(des) {CFileLogger::Write(des); RDEBUG8(des);} |
|
40 #define LOGDES16(des) {CFileLogger::Write(des); RDEBUG16(des);} |
|
41 #define LOGERR(txt,err) if (!err) {} else {LOGARG(txt, err);} |
|
42 #define LOGCALL(exp) {LOGARG("Calling \"%s\"", #exp); exp; LOGARG("Call to \"%s\" passed.", #exp);} |
|
43 #define LOGENTER LOGARG("%s start", __PRETTY_FUNCTION__) |
|
44 #define LOGEXIT LOGARG("%s end", __PRETTY_FUNCTION__) |
|
45 #define LOGMEM(ptr) LOGARG("%s [0x%x]", #ptr, (TUint)ptr) |
|
46 |
|
47 NONSHARABLE_CLASS( CFileLogger ): public CBase |
|
48 { |
|
49 public: |
|
50 static void Write(const TDesC8& aText); |
|
51 static void Write(const TDesC16& aText); |
|
52 static void Write(TRefByValue<const TDesC8> aFmt,...); |
|
53 static void Close(); |
|
54 static void Flush(); |
|
55 |
|
56 private: |
|
57 CFileLogger(); |
|
58 ~CFileLogger(); |
|
59 TBool Construct(); |
|
60 static CFileLogger* Logger(); |
|
61 void DoWrite(); |
|
62 TBool GetLogFileNameWithoutExt(TDes& aFileName); |
|
63 void DoFlush() ; |
|
64 |
|
65 private: |
|
66 RFs iFs; |
|
67 RFile iFile; |
|
68 TBuf8<KMaxLogEntrySize> iLogBuffer; |
|
69 }; |
|
70 |
|
71 #else |
|
72 #define LOGFLUSH |
|
73 #define LOGCLOSE |
|
74 #define LOGARG(txt,parm...) |
|
75 #define LOGTXT(txt) |
|
76 #define LOGDES8(des) |
|
77 #define LOGDES16(des) |
|
78 #define LOGERR(txt,err) |
|
79 #define LOGCALL(exp) |
|
80 #define LOGENTER |
|
81 #define LOGEXIT |
|
82 #define LOGMEM(ptr) |
|
83 #endif |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 #endif // __FILELOGGER_H__ |