os/graphics/windowing/windowserver/debuglog/DebLogRD.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 	_LIT(KDebugFormatString, "%S");
    59 	RDebug::Print(KDebugFormatString, &buf);
    60 	}
    61 
    62 void CDebugLogPrint::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
    63 	{
    64 	TBuf16<256> buf;
    65 	TInt pos=aDes.LocateReverse(' ');
    66 	if (pos<0)
    67 		pos=0;
    68 	buf.Copy(aDes.Mid(pos));
    69 	buf.Append(' ');
    70 	TInt bufLen=buf.Length();
    71 	TPtr16 ptr(&buf[bufLen],buf.MaxLength()-bufLen);
    72 	ptr.Copy(aDes2);
    73 	buf.SetLength(bufLen+aDes2.Length());
    74 	_LIT(KDebugFormatString, "%S");
    75 	RDebug::Print(KDebugFormatString, &buf);	
    76 	}
    77