uiacceltk/hitchcock/plugins/alftranseffect/alftranseffectplugin/src/debuglogger.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     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 "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:   Utility for debug prints to file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //File only compiled with one of these debug flags enabled.
       
    21 #if defined(TFXSERVER_TIME_LOG) || defined(WSSERVERDRAWER_TIME_LOG)
       
    22 
       
    23 #include "debuglogger.h"
       
    24 #include <e32debug.h>
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 //---------------------------------------------------------------------
       
    29 //
       
    30 //---------------------------------------------------------------------
       
    31 CDebugLogger::CDebugLogger()
       
    32 	{
       
    33 	}
       
    34 	
       
    35 CDebugLogger::~CDebugLogger() 
       
    36 	{
       
    37 	iEntries.ResetAndDestroy();
       
    38 	}
       
    39 
       
    40 //---------------------------------------------------------------------
       
    41 // 
       
    42 //---------------------------------------------------------------------	  
       
    43 void CDebugLogger::Log(const TDesC16& aMsg) 
       
    44 	{
       
    45 	CLogEntry *entry = new CLogEntry(aMsg,0);
       
    46 	if(entry)
       
    47 		{
       
    48 		if(KErrNone != iEntries.Append(entry))
       
    49 			{
       
    50 			delete entry;
       
    51 			}
       
    52 		}
       
    53 	}
       
    54 
       
    55 //---------------------------------------------------------------------
       
    56 //
       
    57 //---------------------------------------------------------------------	  
       
    58 void CDebugLogger::Log1(const TDesC16& aMsg, TInt aArg1) 
       
    59 	{
       
    60 	CLogEntry *entry = new CLogEntry(aMsg, 1, aArg1);
       
    61 	if(entry)
       
    62 		{
       
    63 		if(KErrNone != iEntries.Append(entry))
       
    64 			{
       
    65 			delete entry;
       
    66 			}
       
    67 		}
       
    68 	}
       
    69 
       
    70 //---------------------------------------------------------------------
       
    71 //
       
    72 //---------------------------------------------------------------------	  
       
    73 void CDebugLogger::Log2(const TDesC16& aMsg, TInt aArg1, TInt aArg2) 
       
    74 	{
       
    75 	CLogEntry *entry = new CLogEntry(aMsg, 2, aArg1, aArg2);
       
    76 	if(entry)
       
    77 		{
       
    78 		if(KErrNone != iEntries.Append(entry))
       
    79 			{
       
    80 			delete entry;
       
    81 			}
       
    82 		}
       
    83 	}
       
    84 
       
    85 //---------------------------------------------------------------------
       
    86 //
       
    87 //---------------------------------------------------------------------	  
       
    88 void CDebugLogger::Log3(const TDesC16& aMsg, TInt aArg1, TInt aArg2, TInt aArg3) 
       
    89 	{
       
    90 	CLogEntry *entry = new CLogEntry(aMsg, 3, aArg1, aArg2, aArg3);
       
    91 	if(entry)
       
    92 		{
       
    93 		iEntries.Append(entry);
       
    94 		}
       
    95 	}
       
    96 
       
    97 //---------------------------------------------------------------------
       
    98 //
       
    99 //---------------------------------------------------------------------	  
       
   100 void CDebugLogger::Log4(const TDesC16& aMsg, TInt aArg1, TInt aArg2, TInt aArg3, TInt aArg4) 
       
   101 	{
       
   102 	CLogEntry *entry = new CLogEntry(aMsg, 4, aArg1, aArg2, aArg3, aArg4);
       
   103 	if(entry)
       
   104 		{
       
   105 		iEntries.Append(entry);
       
   106 		}
       
   107 	}
       
   108 
       
   109 //---------------------------------------------------------------------
       
   110 //
       
   111 //---------------------------------------------------------------------	  
       
   112 void CDebugLogger::WriteToFile(const TDesC& aLogDir, const TDesC& aLogFile) 
       
   113 	{
       
   114 	const TInt count = iEntries.Count();
       
   115 	/*lint -e1032 -e1023 */
       
   116 	/* 	this is to prevent lint errors that says that writeformat is ambigious and cant be used
       
   117 		without an object, writeformat is not ambigious - it has one static and one non-static version */
       
   118 	for(TInt i = 0; i < count; i++)
       
   119 		{
       
   120 		switch(iEntries[i]->iNbrArgs)
       
   121 			{
       
   122 			case 0:
       
   123 				RFileLogger::Write(aLogDir,aLogFile,EFileLoggingModeAppend,*(iEntries[i]->iMsg));
       
   124 				break;
       
   125 			case 1:
       
   126 				RFileLogger::WriteFormat(aLogDir,aLogFile,EFileLoggingModeAppend,*(iEntries[i]->iMsg),iEntries[i]->iArg1);
       
   127 				break;
       
   128 			case 2:
       
   129 				RFileLogger::WriteFormat(aLogDir,aLogFile,EFileLoggingModeAppend,*(iEntries[i]->iMsg),iEntries[i]->iArg1,iEntries[i]->iArg2);
       
   130 				break;
       
   131 			case 3:
       
   132 				RFileLogger::WriteFormat(aLogDir,aLogFile,EFileLoggingModeAppend,*(iEntries[i]->iMsg),iEntries[i]->iArg1,iEntries[i]->iArg2,iEntries[i]->iArg3);
       
   133 				break;
       
   134 			case 4:
       
   135 				RFileLogger::WriteFormat(aLogDir,aLogFile,EFileLoggingModeAppend,*(iEntries[i]->iMsg),iEntries[i]->iArg1,iEntries[i]->iArg2,iEntries[i]->iArg3,iEntries[i]->iArg4);
       
   136 				break;
       
   137 			default:
       
   138 				break;
       
   139 			}
       
   140 		}
       
   141 	/*lint +e1032 +e1023 */
       
   142 	iEntries.ResetAndDestroy();
       
   143 	}
       
   144 
       
   145 //---------------------------------------------------------------------
       
   146 //
       
   147 //---------------------------------------------------------------------
       
   148 TUint32 CDebugLogger::TimeMs()
       
   149 	{
       
   150 	TTime now;
       
   151 	now.UniversalTime();
       
   152 	return (TUint32)(now.Int64()/1000);
       
   153 	}
       
   154 
       
   155 //---------------------------------------------------------------------
       
   156 //
       
   157 //---------------------------------------------------------------------	
       
   158 CLogEntry::CLogEntry(const TDesC16& aMsg, TInt aNbrArg, TInt aArg1, TInt aArg2, TInt aArg3, TInt aArg4) :  iNbrArgs(aNbrArg), 
       
   159 					iArg1(aArg1), iArg2(aArg2), iArg3(aArg3), iArg4(aArg4) 
       
   160 	{
       
   161 	iMsg = HBufC16::New(aMsg.Length());
       
   162 	if(iMsg)
       
   163 	    {
       
   164     	(*iMsg) = aMsg;
       
   165 	    }
       
   166 	}	  
       
   167 
       
   168 //---------------------------------------------------------------------
       
   169 //
       
   170 //---------------------------------------------------------------------		
       
   171 CLogEntry::~CLogEntry()
       
   172 	{
       
   173 	delete iMsg;
       
   174 	}
       
   175 
       
   176 
       
   177 #endif // TFXSERVER_TIME_LOG
       
   178