24
|
1 |
// Copyright (c) 1997-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 "mSLOGGER.H" // Header file for this source file
|
|
17 |
#include <flogger.h> // for FLogger
|
|
18 |
|
|
19 |
_LIT(KLogFolder,"etel");
|
|
20 |
_LIT(KLogFileName,"mmtsy.txt");
|
|
21 |
_LIT8(KTimeFormat,"%02d:%02d:%02d.%03d ");
|
|
22 |
|
|
23 |
const TInt KTSYLogBufferSize=400;
|
|
24 |
|
|
25 |
void TSYLogger::Write(const TDesC8& aText)
|
|
26 |
{
|
|
27 |
//
|
|
28 |
// Assemble time stamp and callers text into one string
|
|
29 |
TBuf8<KTSYLogBufferSize> buf;
|
|
30 |
TTime now;
|
|
31 |
now.UniversalTime();
|
|
32 |
TDateTime t(now.DateTime());
|
|
33 |
buf.Format(KTimeFormat,t.Hour(),t.Minute(),t.Second(),t.MicroSecond());
|
|
34 |
buf.Append(aText);
|
|
35 |
|
|
36 |
//
|
|
37 |
// Open log, write text to log and close log
|
|
38 |
RFileLogger log;
|
|
39 |
if(KErrNone==log.Connect())
|
|
40 |
{
|
|
41 |
log.CreateLog(KLogFolder,KLogFileName,EFileLoggingModeAppend);
|
|
42 |
log.SetDateAndTime(EFalse,EFalse);
|
|
43 |
log.Write(buf);
|
|
44 |
log.CloseLog();
|
|
45 |
log.Close();
|
|
46 |
}
|
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
void TSYLogger::WriteFormat(TRefByValue<const TDesC8> aFmt,...)
|
|
51 |
{
|
|
52 |
//coverity[var_decl]
|
|
53 |
VA_LIST list;
|
|
54 |
VA_START(list,aFmt);
|
|
55 |
|
|
56 |
//
|
|
57 |
// Assemble time stamp and callers text into one string
|
|
58 |
TBuf8<KTSYLogBufferSize> buf;
|
|
59 |
TTime now;
|
|
60 |
now.UniversalTime();
|
|
61 |
TDateTime t(now.DateTime());
|
|
62 |
buf.Format(KTimeFormat,t.Hour(),t.Minute(),t.Second(),t.MicroSecond());
|
|
63 |
//coverity[uninit_use_in_call]
|
|
64 |
buf.AppendFormatList(aFmt,list);
|
|
65 |
|
|
66 |
//
|
|
67 |
// Open log, write text to log and close log
|
|
68 |
RFileLogger log;
|
|
69 |
if(KErrNone==log.Connect())
|
|
70 |
{
|
|
71 |
log.CreateLog(KLogFolder,KLogFileName,EFileLoggingModeAppend);
|
|
72 |
log.SetDateAndTime(EFalse,EFalse);
|
|
73 |
log.Write(buf);
|
|
74 |
log.CloseLog();
|
|
75 |
log.Close();
|
|
76 |
}
|
|
77 |
}
|
|
78 |
|