First public contribution.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "logservpanic.h"
17 #include "LogServSqlStrings.h"
20 // RMessage::Panic() also completes the message. This is:
21 // (a) important for efficient cleanup within the kernel
22 // (b) a problem if the message is completed a second time
24 void PanicClientL(const RMessage2& aMessage, TLogServPanic aPanic)
26 aMessage.Panic(KLogServ, aPanic);
27 User::Leave(KLogPanicLeave);
30 void PanicClient(const RMessage2& aMessage, TLogServPanic aPanic)
32 aMessage.Panic(KLogServ, aPanic);
35 #pragma BullseyeCoverage off
37 void Panic(TLogServPanic aPanic)
39 User::Panic(KLogServ, aPanic);
42 #pragma BullseyeCoverage on
44 #ifdef LOGGING_ENABLED
46 const TInt KLogEngLogBufferSize = 256;
50 _LIT(KNewLogText, "===== NEW LOG =====");
53 TInt ret=logger.Connect();
56 logger.CreateLog(KLogFolder, KLogFileName, EFileLoggingModeOverwrite);
57 logger.Write(KNewLogText);
62 void Log::Write(const TDesC& aText)
67 TInt ret=logger.Connect();
70 logger.SetDateAndTime(EFalse,EFalse);
71 logger.CreateLog(KLogFolder, KLogFileName,EFileLoggingModeAppend);
72 TBuf<KLogEngLogBufferSize> buf;
74 // The debug log uses hometime rather than UTC for its timestamps. This is
75 // purely a debugging aid.
79 dateTime = now.DateTime();
80 buf.Format(KTimeFormat,dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
81 buf.AppendFormat(KTextFormat,&aText);
89 void Log::WriteFormat(TRefByValue<const TDesC> aFmt,...)
96 TBuf<2*KLogEngLogBufferSize> buf;
100 // The debug log uses hometime rather than UTC for its timestamps. This is
101 // purely a debugging aid.
105 dateTime = now.DateTime();
106 buf.Format(KTimeFormat,dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
107 buf.AppendFormatList(aFmt, list );
110 TInt ret=logger.Connect();
113 logger.SetDateAndTime(EFalse,EFalse);
114 logger.CreateLog(KLogFolder, KLogFileName,EFileLoggingModeAppend);
122 void Log::PruneLogFile()
124 const TInt KMaxLogSize = 1024 * 500;
126 _LIT(KBaseFolder, "_:\\Logs\\");
127 TFileName fileName(KBaseFolder);
128 fileName[0] = 'A' + static_cast<TInt>(RFs::GetSystemDrive());
129 fileName.Append(KLogFolder);
130 fileName.Append(KPathDelimiter);
131 fileName.Append(KLogFileName);
134 if (fsSession.Connect() == KErrNone)
137 if (fsSession.Entry(fileName, entry) == KErrNone)
139 // Check size and delete if its too big
140 if (entry.iSize >= KMaxLogSize)
142 TInt fileDeleteErr=fsSession.Delete(fileName);
143 // If a debug build - record error
145 if (fileDeleteErr != KErrNone)
147 RDebug::Print(_L("Log::PruneLogFile - Failed to delete file. Error = %d"), fileDeleteErr);