sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "LogServShared.h" sl@0: #include "LogServServer.h" sl@0: #include "LogServScheduler.h" sl@0: #include "logservpanic.h" sl@0: sl@0: static void StartLogServerL() sl@0: // sl@0: // Perform all server initialisation, in particular creation of the sl@0: // scheduler and server and then run the scheduler sl@0: // sl@0: { sl@0: #if defined(LOGGING_CREATE_LOG_DIRECTORY) && defined(LOGGING_ENABLED) sl@0: RFs fsSession; sl@0: if (fsSession.Connect() == KErrNone) sl@0: { sl@0: _LIT(KBaseFolder, "_:\\Logs\\"); sl@0: TFileName path(KBaseFolder); sl@0: path[0] = 'A' + static_cast(RFs::GetSystemDrive()); sl@0: path += KLogFolder; sl@0: path.Append(KPathDelimiter); sl@0: fsSession.MkDirAll(path); // ignore error sl@0: } sl@0: fsSession.Close(); sl@0: sl@0: //LOGNEW; sl@0: sl@0: // For !WINS or all EKA2 builds this is needed sl@0: // Write the process location sl@0: TFileName processName(RProcess().FileName()); sl@0: LOGTEXT2("StartLogServerL(%S)", &processName); sl@0: sl@0: #endif sl@0: sl@0: // Naming the server thread after the server helps to debug panics sl@0: LOGTEXT("StartLogServerL() - about to rename thread"); sl@0: User::LeaveIfError(User::RenameThread(KLogServerName)); sl@0: sl@0: // Create and install the active scheduler we need sl@0: CActiveScheduler* scheduler = new(ELeave)CLogActiveScheduler; sl@0: CleanupStack::PushL(scheduler); sl@0: CActiveScheduler::Install(scheduler); sl@0: sl@0: // create the server (leave it on the cleanup stack) sl@0: LOGTEXT("StartLogServerL() - about to create server object"); sl@0: CLogServServer::NewLC(); sl@0: sl@0: // Initialisation complete, now signal the client sl@0: LOGTEXT("StartLogServerL() - about to signal client thread"); sl@0: RProcess::Rendezvous(KErrNone); sl@0: // Start the scheduler and wait for clien requests sl@0: LOGTEXT("StartLogServerL() - about to start scheduler"); sl@0: CActiveScheduler::Start(); sl@0: sl@0: // Cleanup the server and scheduler sl@0: LOGTEXT("StartLogServerL() - scheduler stopped, exiting main log engine server thread"); sl@0: CleanupStack::PopAndDestroy(2, scheduler); sl@0: } sl@0: sl@0: TInt E32Main() sl@0: // sl@0: // Server process entry-point sl@0: // Recover the startup parameters and run the server sl@0: // sl@0: { sl@0: __UHEAP_MARK; sl@0: // sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: TInt r=KErrNoMemory; sl@0: if (cleanup) sl@0: { sl@0: TRAP(r,StartLogServerL()); sl@0: delete cleanup; sl@0: } sl@0: // sl@0: __UHEAP_MARKEND; sl@0: return r; sl@0: } sl@0: sl@0: