sl@0
|
1 |
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// code that logs using RDebug::Print
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "DebLogRD.H"
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
EXPORT_C CDebugLogBase *CreateDebugLog(TBool aIsFirst, TDesC &aParams)
|
sl@0
|
22 |
{
|
sl@0
|
23 |
CDebugLogPrint *device=new(ELeave) CDebugLogPrint();
|
sl@0
|
24 |
CDebugLog *log=NULL;
|
sl@0
|
25 |
TRAPD(err,log=new(ELeave) CDebugLog(device));
|
sl@0
|
26 |
if (err!=KErrNone)
|
sl@0
|
27 |
{
|
sl@0
|
28 |
delete device;
|
sl@0
|
29 |
User::Leave(err);
|
sl@0
|
30 |
}
|
sl@0
|
31 |
TRAP(err,log->ConstructL(aIsFirst, aParams));
|
sl@0
|
32 |
if (err!=KErrNone)
|
sl@0
|
33 |
{
|
sl@0
|
34 |
delete log;
|
sl@0
|
35 |
User::Leave(err);
|
sl@0
|
36 |
}
|
sl@0
|
37 |
return(log);
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
CDebugLogPrint::CDebugLogPrint()
|
sl@0
|
41 |
{}
|
sl@0
|
42 |
|
sl@0
|
43 |
CDebugLogPrint::~CDebugLogPrint()
|
sl@0
|
44 |
{}
|
sl@0
|
45 |
|
sl@0
|
46 |
void CDebugLogPrint::ConstructL(TBool /*aIsFirst*/, TDesC& /*aParams*/)
|
sl@0
|
47 |
{}
|
sl@0
|
48 |
|
sl@0
|
49 |
void CDebugLogPrint::WriteToLogL(const TDesC &aDes, const TDesC &aDes2)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
TBuf<256> buf;
|
sl@0
|
52 |
TInt pos=aDes.LocateReverse(' ');
|
sl@0
|
53 |
if (pos<0)
|
sl@0
|
54 |
pos=0;
|
sl@0
|
55 |
buf.Copy(aDes.Mid(pos));
|
sl@0
|
56 |
buf.Append(' ');
|
sl@0
|
57 |
buf.Append(aDes2);
|
sl@0
|
58 |
_LIT(KDebugFormatString, "%S");
|
sl@0
|
59 |
RDebug::Print(KDebugFormatString, &buf);
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
void CDebugLogPrint::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
TBuf16<256> buf;
|
sl@0
|
65 |
TInt pos=aDes.LocateReverse(' ');
|
sl@0
|
66 |
if (pos<0)
|
sl@0
|
67 |
pos=0;
|
sl@0
|
68 |
buf.Copy(aDes.Mid(pos));
|
sl@0
|
69 |
buf.Append(' ');
|
sl@0
|
70 |
TInt bufLen=buf.Length();
|
sl@0
|
71 |
TPtr16 ptr(&buf[bufLen],buf.MaxLength()-bufLen);
|
sl@0
|
72 |
ptr.Copy(aDes2);
|
sl@0
|
73 |
buf.SetLength(bufLen+aDes2.Length());
|
sl@0
|
74 |
_LIT(KDebugFormatString, "%S");
|
sl@0
|
75 |
RDebug::Print(KDebugFormatString, &buf);
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|