omacpadapters/WAPAdapter/Src/WPWAPAdapterMain.cpp
changeset 42 aa33c2cb9a50
equal deleted inserted replaced
41:c742e1129640 42:aa33c2cb9a50
       
     1 /*
       
     2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  DLL entry point
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32debug.h>
       
    22 #include <e32std.h>
       
    23 #include <flogger.h>
       
    24 #include "WPWAPDebug.h"
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 #ifdef WAPDEBUG
       
    29 #ifdef WINS
       
    30 /// Folder where the log resides
       
    31 _LIT( KLogFolder, "provisioning" );
       
    32 
       
    33 /// The name of the log file
       
    34 _LIT( KLogFileName, "wapadapter" );
       
    35 
       
    36 /// The format in which the time is formatted in log
       
    37 _LIT( KLogTimeFormat, "%02d.%02d:%02d:%06d ");
       
    38 
       
    39 /// The length of the string produced by KLogTimeFormat
       
    40 const TInt KLogTimeFormatLength = 16;
       
    41 
       
    42 /// How many characters a log line can contain
       
    43 const TInt KLogLineLength = 256;
       
    44 #endif
       
    45 #endif 
       
    46 
       
    47 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // Debug
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 #ifdef WAPDEBUG
       
    54 GLDEF_C void Debug( TRefByValue<const TDesC> aText, ... )
       
    55     {
       
    56     #ifdef WINS
       
    57     VA_LIST args;
       
    58     VA_START( args, aText );
       
    59 
       
    60     TBuf<KLogLineLength> buf;
       
    61     buf.FormatList( aText, args );
       
    62 
       
    63     RFileLogger logger;
       
    64     TInt ret=logger.Connect();
       
    65     if (ret==KErrNone)
       
    66         {
       
    67         logger.SetDateAndTime( EFalse,EFalse );
       
    68         logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend );       
       
    69         TBuf<KLogTimeFormatLength> timeStamp;
       
    70         TTime now;
       
    71         now.HomeTime();
       
    72         TDateTime dateTime;
       
    73         dateTime = now.DateTime();
       
    74         timeStamp.Format( KLogTimeFormat, 
       
    75             dateTime.Hour(), dateTime.Minute(),
       
    76             dateTime.Second(), dateTime.MicroSecond() );
       
    77         buf.Insert( 0, timeStamp );
       
    78 
       
    79         logger.Write(buf);
       
    80         }
       
    81 
       
    82     logger.Close();
       
    83 
       
    84     VA_END( args );
       
    85     #else
       
    86     RDebug::Print(aText);
       
    87     #endif
       
    88     }
       
    89 #else
       
    90 GLDEF_C void Debug( TRefByValue<const TDesC> /*aText*/, ... )
       
    91     {
       
    92     }
       
    93 #endif
       
    94 
       
    95 //  End of File