|
1 /* |
|
2 * Copyright (c) 2009 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: This class provides function that help in logging entry and exit of APIs of classes |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "apilogger.h" |
|
20 #include <qdatetime.h> |
|
21 |
|
22 #ifdef POSINDICATOR_NFT |
|
23 const char* debugFileName("c://logs//lbs//posindicatornftlog.txt"); |
|
24 #else |
|
25 const char* debugFileName("c://logs//lbs//posindicatorlog.txt"); |
|
26 #endif |
|
27 |
|
28 ofstream logfile; |
|
29 QFile file( debugFileName ); |
|
30 |
|
31 void ApiLogger::OpenLogFile() |
|
32 { |
|
33 #ifdef POSINDICATOR_NFT |
|
34 file.open( QIODevice::ReadWrite | QIODevice::Text ) ; |
|
35 #else |
|
36 logfile.open(debugFileName, ios::app); |
|
37 #endif |
|
38 } |
|
39 |
|
40 void ApiLogger::CloseLogFile() |
|
41 { |
|
42 #ifdef POSINDICATOR_NFT |
|
43 file.close(); |
|
44 #else |
|
45 logfile.flush(); |
|
46 logfile.close(); |
|
47 #endif |
|
48 |
|
49 } |
|
50 |
|
51 void ApiLogger::MyOutputHandler(QtMsgType type, const char *msg) |
|
52 { |
|
53 switch (type) { |
|
54 case QtDebugMsg: |
|
55 logfile << QTime::currentTime().toString().toAscii().data() << " Debug: " << msg << "\n"; |
|
56 break; |
|
57 case QtCriticalMsg: |
|
58 logfile << QTime::currentTime().toString().toAscii().data() << " Critical: " << msg << "\n"; |
|
59 break; |
|
60 case QtWarningMsg: |
|
61 // logfile << QTime::currentTime().toString().toAscii().data() << " Warning: " << msg << "\n"; |
|
62 break; |
|
63 case QtFatalMsg: |
|
64 logfile << QTime::currentTime().toString().toAscii().data() << " Fatal: " << msg << "\n"; |
|
65 default: |
|
66 break; |
|
67 } |
|
68 logfile.flush(); |
|
69 } |
|
70 |
|
71 |
|
72 |
|
73 void ApiLogger::NftLogger( const QString msg ) |
|
74 { |
|
75 QString displayString( msg ); |
|
76 #ifdef POSINDICATOR_NFT |
|
77 QTextStream stream( &file ); |
|
78 QString display( QTime::currentTime().toString("h:m:s:z") ); |
|
79 display.append( displayString ); |
|
80 stream << display; |
|
81 stream.flush(); |
|
82 #endif |
|
83 } |
|
84 |