Example Application Guide

- Main Page
- Classes
- Files

# geoprofilesdebug.cpp

    00001 /*
    00002 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
    00003 * All rights reserved.
    00004 * This component and the accompanying materials are made available
    00005 * under the terms of the License "Eclipse Public License v1.0"
    00006 * which accompanies this distribution, and is available
    00007 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    00008 *
    00009 * Initial Contributors:
    00010 * Nokia Corporation - initial contribution.
    00011 *
    00012 * Contributors:
    00013 *
    00014 * Description:  Geo Profile Debug
    00015 *
    00016 */
    00017
    00018
    00019
    00020 // INCLUDE FILES
    00021 #include "geoprofilesdebug.h"
    00022 #include <flogger.h>
    00023 #include <e32svr.h>
    00024 #include <f32file.h>
    00025 #include <bautils.h>
    00026
    00027 // CONSTANTS
    00028
    00029 /// Folder where the log resides
    00030 _LIT( KGeoProfilesLogFolder, "epos" );
    00031
    00032 /// The name of the log file
    00033 _LIT( KGeoProfilesLogFileName, "GeoProfiles.txt" );
    00034
    00035 /// The format in which the time is formatted in log
    00036 _LIT( KGeoProfilesLogTimeFormat, "%02d.%02d:%02d:%06d ");
    00037
    00038 /// The length of the string produced by KLocLogTimeFormat
    00039 const TInt KGeoProfilesLogTimeFormatLength = 16;
    00040
    00041 /// How many characters a log line can contain
    00042 const TInt KGeoProfilesLogLineLength = 256;
    00043
    00044 // ========================== OTHER EXPORTED FUNCTIONS =========================
    00045
    00046
    00047
    00048 // -----------------------------------------------------------------------------
    00049 // Debug
    00050 // Generates a log file if c:\logs\eventsui\ folder exists
    00051 // -----------------------------------------------------------------------------
    00052 //
    00053 void Debug( TRefByValue<const TDesC> aText, ... )
    00054     {
    00055     VA_LIST args;
    00056     VA_START( args, aText );
    00057
    00058     TBuf< KGeoProfilesLogLineLength > buf;
    00059     buf.FormatList( aText, args );
    00060
    00061     #ifdef _DEBUG
    00062         RDebug::Print(buf);
    00063     #endif
    00064
    00065     RFileLogger logger;
    00066     TInt ret = logger.Connect();
    00067     if ( ret == KErrNone )
    00068         {
    00069         logger.SetDateAndTime( EFalse,EFalse );
    00070         logger.CreateLog( KGeoProfilesLogFolder, KGeoProfilesLogFileName, EFileLoggingModeAppend );
    00071         TBuf< KGeoProfilesLogTimeFormatLength > timeStamp;
    00072         TTime now;
    00073         now.HomeTime();
    00074         TDateTime dateTime;
    00075         dateTime = now.DateTime();
    00076         timeStamp.Format( KGeoProfilesLogTimeFormat,
    00077                           dateTime.Hour(),
    00078                           dateTime.Minute(),
    00079                           dateTime.Second(),
    00080                           dateTime.MicroSecond());
    00081         buf.Insert( 0, timeStamp );
    00082
    00083         logger.Write(buf);
    00084         }
    00085
    00086     logger.Close();
    00087
    00088     VA_END( args );
    00089     }

© Nokia 2009 |