Exemple #1
0
    bool DiCommandManager::Init()
    {
        DI_INFO("Command manager is initializing...");

        CommandMgr = this;
        DiSystemCmd::BindAllSystemCmd(this);
        
#if DEMI_PLATFORM == DEMI_PLATFORM_WIN32
        InitConsoleLogger(true);
#endif
        return true;
    }
Exemple #2
0
/** Function to initialize the logger. */
int InitLogger(LogDest ldest,void* loggerInitParams)
{
	int retVal = 0;
	if(pLogWriter)
	{
		fprintf(stderr,"\n [liblogger]Deinitializing the current log writer\n");
		DeInitLogger();
	}
#ifndef DISABLE_THREAD_SAFETY
	if(!sMutex)
		PLCreateMutex(&sMutex);
#endif
	__LOCK_MUTEX;

	switch(ldest)
	{
		/* log to a socket. */
		case LogToSocket:
			#ifndef DISABLE_SOCKET_LOGGER
			{
				if( -1 == InitSocketLogger(&pLogWriter,loggerInitParams) )
				{
					fprintf(stderr,"\n [liblogger] could not init socket logging \n");
					retVal = -1;
					goto UNLOCK_RETURN;
				}
			}
			#else
			{
				fprintf(stderr,"\n [liblogger] Socket logger not enabled during build\n");
				retVal = -1;
				goto UNLOCK_RETURN;
			}
			#endif
			break;

		/* log to a console. */
		case LogToConsole:
			{
				if( -1 == InitConsoleLogger(&pLogWriter,loggerInitParams) )
				{
					/* control should never reach here, this should always succeed. */
					fprintf(stderr,"\n [liblogger] could not initialize console logger \n");
					retVal = -1;
					goto UNLOCK_RETURN;
				}
			}
		break;

		/* log to a file. */
		case LogToFile:
			{
				if( -1 == InitFileLogger(&pLogWriter,loggerInitParams) )
				{
					fprintf(stderr,"\n [liblogger] could not initialize file logger, check file path/name \n");
					retVal = -1;
					goto UNLOCK_RETURN;
				}
			}
			break;
	}
	retVal = 0;
UNLOCK_RETURN:
	__UNLOCK_MUTEX;
	return retVal; /* success. */
}