browserui/browser/BrowserAppSrc/Logger.cpp
changeset 51 48e827313edd
parent 37 481242ead638
child 53 f427d27b98d8
equal deleted inserted replaced
37:481242ead638 51:48e827313edd
     1 /*
       
     2 * Copyright (c) 2002 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:  Implemented logger functionality of the module
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #if defined( I__BROWSER_LOG_ENABLED ) 
       
    20 
       
    21 // INCLUDES
       
    22 
       
    23 #include "Logger.h"
       
    24 
       
    25 // CONSTANTS
       
    26 
       
    27 // the indentation value used in every function entry and exit points
       
    28 // use value 0 to switch indentation off
       
    29 const TInt KBrowserIndentValue = 0;
       
    30 
       
    31 // the left x character of this string is used to indent
       
    32 // function entry and exit points. DO NOT cut is smaller!
       
    33 // it has to be synched with the call stack level and KBrowserIndentValue:
       
    34 // .Length() / KBrowserIndentValue >= max size of callstack
       
    35 _LIT( KBrowserLoggerIndentString,
       
    36 "                                                                      " );
       
    37 _LIT( KDebugLogEnterFn,         "Browser: %S-> %S" );
       
    38 _LIT( KDebugLogLeaveFn,         "Browser: %S<- %S" );
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 
       
    42 // initialize static member variable
       
    43 #if defined ( I__BROWSER_LOG_INDENT )
       
    44 TInt CBrowserLogger::iIndent( 0 );
       
    45 #endif
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 
       
    49 CBrowserLogger::CBrowserLogger( const TDesC& aFunc )
       
    50         : iFunc( aFunc )
       
    51 #if ! defined ( I__BROWSER_LOG_INDENT )
       
    52         , iIndent( 0 )
       
    53 #endif
       
    54     {
       
    55     TPtrC a = KBrowserLoggerIndentString().Left( iIndent );
       
    56     iIndent += KBrowserIndentValue;
       
    57     RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile,
       
    58         EFileLoggingModeAppend, KDebugLogEnterFn, &a, &iFunc );
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 
       
    63 CBrowserLogger::~CBrowserLogger()
       
    64     {
       
    65     iIndent -= KBrowserIndentValue;
       
    66     TPtrC a = KBrowserLoggerIndentString().Left( iIndent );
       
    67     RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile,
       
    68         EFileLoggingModeAppend, KDebugLogLeaveFn, &a, &iFunc );
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 
       
    73 void CBrowserLogger::Write( TRefByValue<const TDesC16> aFmt, ... )
       
    74     {
       
    75     VA_LIST list;
       
    76     VA_START( list, aFmt );
       
    77     RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile, 
       
    78         EFileLoggingModeAppend, aFmt, list );
       
    79     VA_END( list );
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 
       
    84 void CBrowserLogger::Write( TRefByValue<const TDesC16> aFmt, VA_LIST& aList )
       
    85     {
       
    86     RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile,
       
    87         EFileLoggingModeAppend, aFmt, aList );
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 
       
    92 void CBrowserLogger::Write(TRefByValue<const TDesC8> aFmt, ... )
       
    93     {
       
    94     VA_LIST list;
       
    95     VA_START( list, aFmt );
       
    96     RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile,
       
    97         EFileLoggingModeAppend, aFmt, list );
       
    98     VA_END( list );
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 
       
   103 void CBrowserLogger::Write( TRefByValue<const TDesC8> aFmt, VA_LIST& aList )
       
   104     {
       
   105     RFileLogger::WriteFormat( KDebugLogDir, KDebugLogFile,
       
   106         EFileLoggingModeAppend, aFmt, aList );
       
   107     }
       
   108     
       
   109     
       
   110 // Code segment for displaying an info note dialog box.  Can be used later as a debug aid.
       
   111 
       
   112     /*
       
   113     TInt    width, height;
       
   114     HBufC* header;
       
   115     TBuf<100> message; 
       
   116 
       
   117     message.Format(_L("width: %d ; height: %d"), width, height );
       
   118 
       
   119     header = StringLoader::LoadLC( R_WML_SECURITY_VIEW_TITLE );    
       
   120 
       
   121     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( message );
       
   122 
       
   123     dlg->PrepareLC( R_BROWSER_SECURITY_INFO );
       
   124     CAknPopupHeadingPane* hPane = dlg->QueryHeading();
       
   125     if ( hPane )
       
   126     {
       
   127     hPane->SetTextL( *header );
       
   128     }
       
   129     dlg->RunLD();
       
   130     CleanupStack::PopAndDestroy( 1 ); // header
       
   131     */
       
   132 
       
   133 
       
   134 #endif // I__BROWSER_LOG_ENABLED
       
   135 
       
   136 // End of file