loggingservices/eventlogger/LogServ/src/LogServStartup.cpp
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "LogServShared.h"
       
    17 #include "LogServServer.h"
       
    18 #include "LogServScheduler.h"
       
    19 #include "logservpanic.h"
       
    20 
       
    21 static void StartLogServerL()
       
    22 //
       
    23 // Perform all server initialisation, in particular creation of the
       
    24 // scheduler and server and then run the scheduler
       
    25 //
       
    26 	{
       
    27 #if defined(LOGGING_CREATE_LOG_DIRECTORY) && defined(LOGGING_ENABLED)
       
    28 	RFs fsSession;
       
    29 	if	(fsSession.Connect() == KErrNone)
       
    30 		{
       
    31 		_LIT(KBaseFolder, "_:\\Logs\\");
       
    32 		TFileName path(KBaseFolder);
       
    33 		path[0] = 'A' + static_cast<TInt>(RFs::GetSystemDrive()); 
       
    34 		path += KLogFolder;
       
    35 		path.Append(KPathDelimiter);
       
    36 		fsSession.MkDirAll(path); // ignore error
       
    37 		}
       
    38 	fsSession.Close();
       
    39 
       
    40 	//LOGNEW;
       
    41 
       
    42     // For !WINS or all EKA2 builds this is needed
       
    43  	// Write the process location
       
    44 	TFileName processName(RProcess().FileName());
       
    45 	LOGTEXT2("StartLogServerL(%S)", &processName);
       
    46 
       
    47 #endif
       
    48 
       
    49 	// Naming the server thread after the server helps to debug panics
       
    50 	LOGTEXT("StartLogServerL() - about to rename thread");
       
    51     User::LeaveIfError(User::RenameThread(KLogServerName));
       
    52 
       
    53 	// Create and install the active scheduler we need
       
    54 	CActiveScheduler* scheduler = new(ELeave)CLogActiveScheduler;
       
    55 	CleanupStack::PushL(scheduler);
       
    56 	CActiveScheduler::Install(scheduler);
       
    57 
       
    58 	// create the server (leave it on the cleanup stack)
       
    59 	LOGTEXT("StartLogServerL() - about to create server object");
       
    60 	CLogServServer::NewLC();
       
    61 
       
    62 	// Initialisation complete, now signal the client
       
    63 	LOGTEXT("StartLogServerL() - about to signal client thread");
       
    64 	RProcess::Rendezvous(KErrNone);
       
    65 	// Start the scheduler and wait for clien requests
       
    66 	LOGTEXT("StartLogServerL() - about to start scheduler");
       
    67 	CActiveScheduler::Start();
       
    68 
       
    69 	// Cleanup the server and scheduler
       
    70 	LOGTEXT("StartLogServerL() - scheduler stopped, exiting main log engine server thread");
       
    71 	CleanupStack::PopAndDestroy(2, scheduler);
       
    72 	}
       
    73 
       
    74 TInt E32Main()
       
    75 //
       
    76 // Server process entry-point
       
    77 // Recover the startup parameters and run the server
       
    78 //
       
    79 	{
       
    80 	__UHEAP_MARK;
       
    81 	//
       
    82 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
    83 	TInt r=KErrNoMemory;
       
    84 	if (cleanup)
       
    85 		{
       
    86 		TRAP(r,StartLogServerL());
       
    87 		delete cleanup;
       
    88 		}
       
    89 	//
       
    90 	__UHEAP_MARKEND;
       
    91 	return r;
       
    92 	}
       
    93 
       
    94