windowing/windowserver/debuglog/DebLogRD.CPP
changeset 0 5d03bc08d59c
child 18 5e30ef2e26cb
child 36 01a6848ebfd7
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2003-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 // code that logs using RDebug::Print
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "DebLogRD.H"
       
    19 
       
    20 
       
    21 EXPORT_C CDebugLogBase *CreateDebugLog(TBool aIsFirst, TDesC &aParams)
       
    22 	{
       
    23 	CDebugLogPrint *device=new(ELeave) CDebugLogPrint();
       
    24 	CDebugLog *log=NULL;
       
    25 	TRAPD(err,log=new(ELeave) CDebugLog(device));
       
    26 	if (err!=KErrNone)
       
    27 		{
       
    28 		delete device;
       
    29 		User::Leave(err);
       
    30 		}
       
    31 	TRAP(err,log->ConstructL(aIsFirst, aParams));
       
    32 	if (err!=KErrNone)
       
    33 		{
       
    34 		delete log;
       
    35 		User::Leave(err);
       
    36 		}
       
    37 	return(log);
       
    38 	}
       
    39 
       
    40 CDebugLogPrint::CDebugLogPrint()
       
    41 	{}
       
    42 
       
    43 CDebugLogPrint::~CDebugLogPrint()
       
    44 	{}
       
    45 
       
    46 void CDebugLogPrint::ConstructL(TBool /*aIsFirst*/, TDesC& /*aParams*/)
       
    47 	{}
       
    48 
       
    49 void CDebugLogPrint::WriteToLogL(const TDesC &aDes, const TDesC &aDes2)
       
    50 	{
       
    51 	TBuf<256> buf;
       
    52 	TInt pos=aDes.LocateReverse(' ');
       
    53 	if (pos<0)
       
    54 		pos=0;
       
    55 	buf.Copy(aDes.Mid(pos));
       
    56 	buf.Append(' ');
       
    57 	buf.Append(aDes2);
       
    58 	RDebug::Print(buf);
       
    59 	}
       
    60 
       
    61 void CDebugLogPrint::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
       
    62 	{
       
    63 	TBuf16<256> buf;
       
    64 	TInt pos=aDes.LocateReverse(' ');
       
    65 	if (pos<0)
       
    66 		pos=0;
       
    67 	buf.Copy(aDes.Mid(pos));
       
    68 	buf.Append(' ');
       
    69 	TInt bufLen=buf.Length();
       
    70 	TPtr16 ptr(&buf[bufLen],buf.MaxLength()-bufLen);
       
    71 	ptr.Copy(aDes2);
       
    72 	buf.SetLength(bufLen+aDes2.Length());
       
    73 	RDebug::Print(buf);
       
    74 	}
       
    75