webengine/osswebengine/WebKit/s60/misc/WebKitLogger.cpp
changeset 0 dd21522fd290
child 68 92a765b5b3e7
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 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 the License "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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "config.h"
       
    21 #include "WebKitLogger.h"
       
    22 #include <string.h>
       
    23 #include <E32HAL.H>
       
    24 
       
    25 // EXTERNAL DATA STRUCTURES
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // LOCAL CONSTANTS AND MACROS
       
    34 
       
    35 // MODULE DATA STRUCTURES
       
    36 
       
    37 // LOCAL FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 // ============================= LOCAL FUNCTIONS ===============================
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 LogStream::LogStream() : iLoggerReady( EFalse )
       
    46     {
       
    47     iString.Zero();
       
    48     }
       
    49 
       
    50 LogStream& LogStream::LogStream::operator<<(
       
    51     TInt aInt )
       
    52     {
       
    53     TBuf<10> num;
       
    54     num.Num( aInt );
       
    55     return *this << num;
       
    56     }
       
    57 
       
    58 LogStream& LogStream::operator<<(
       
    59     TUint aUint )
       
    60     {
       
    61     TBuf<10> num;
       
    62     num.Num( aUint );
       
    63     return *this << num;
       
    64     }
       
    65 
       
    66 LogStream& LogStream::operator<<(
       
    67     TReal aReal )
       
    68     {
       
    69   TBuf<32> buffer;
       
    70   buffer.Num( TReal( aReal ), TRealFormat() );
       
    71   return *this<<buffer;
       
    72     }
       
    73 
       
    74 LogStream& LogStream::operator<<(
       
    75     const char* aString )
       
    76     {
       
    77     iString.Append( (unsigned char*)aString, (TInt)strlen( aString ) );
       
    78     return *this;
       
    79     }
       
    80 
       
    81 LogStream& LogStream::operator<<(
       
    82     const TDesC& aString )
       
    83     {
       
    84     iString.Append( aString );
       
    85     return *this;
       
    86     }
       
    87 
       
    88 LogStream& LogStream::operator<<(
       
    89     const TDesC8& aString )
       
    90     {
       
    91     iString.Append( aString );
       
    92     return *this;
       
    93     }
       
    94 
       
    95 LogStream& LogStream::operator<<(
       
    96     TAny* aAny )
       
    97     {
       
    98   TBuf8<32> buffer;
       
    99   buffer.Num( (TUint)aAny, EHex );
       
   100     return *this << buffer;
       
   101     }
       
   102 
       
   103 // LogStream& LogStream::operator<<(const LogStreamManipulator& );
       
   104 void LogStream::flush()
       
   105     {
       
   106     if( !iLoggerReady )
       
   107         {
       
   108         RFileLogger::Write( _L("Browser"), _L("webkit_tot.html"), EFileLoggingModeAppend,
       
   109         _L("<html><head></head><body>") );
       
   110         iLoggerReady = ETrue;
       
   111         }
       
   112     (*this)<<"<br>";
       
   113     RFileLogger::Write( _L("Browser"), _L("webkit_tot.html"), EFileLoggingModeAppend, iString );
       
   114     iString.Zero();
       
   115     }
       
   116 
       
   117 LogStream& flush(
       
   118     LogStream& aStream )
       
   119     {
       
   120     // flush the string to output
       
   121     aStream.flush();
       
   122     return aStream;
       
   123     }
       
   124 
       
   125 void LogStream::mem()
       
   126     {
       
   127     flush();
       
   128     TMemoryInfoV1Buf meminfo;
       
   129     UserHal::MemoryInfo( meminfo );
       
   130     (*this)<<"Mem available:";
       
   131     (*this)<<meminfo().iFreeRamInBytes;
       
   132     }
       
   133 
       
   134 LogStream& mem(
       
   135     LogStream& aStream )
       
   136     {
       
   137     // flush the string to output
       
   138     aStream.mem();
       
   139     return aStream;
       
   140     }
       
   141 
       
   142 //  End of File