コード例 #1
0
ファイル: log.cpp プロジェクト: gityf/log
bool log_init(ELogLevel l, const string& moduleName, const string& logDir) {
    string fullPath = logDir + "/" + moduleName + ".access";
    INFO_W.loginit(l, fullPath);
    fullPath = logDir + "/" + moduleName + ".error";
    WARN_W.loginit(l > LL_WARN ? l : LL_WARN, fullPath);
    return true;
}
コード例 #2
0
/** Extract training pairs from all sgf files found in the
specified directory.
@params path The directory to search for SGF files.
@params db The NNDatabase to store the training pairs in. */
void Urgency3BPNGoTrainer::extractPairsFromDirectory(string path, NNDatabase* db, const GoRankRange* rankRange /*=NULL*/) const
{
	LogWriter log;
	char buffer[200];
	if(_getcwd(buffer, 200)==NULL)
	{
		log.println("Error with _getcwd");
		return;
	}
	if(_chdir(path.c_str())==-1)
	{
		log.println("Error changing directory");
		return;
	}

	vector<string> files;
	getFileList(files, "*.mgt");
	getFileList(files, "*.sgf");


	if(files.size()<=0)
	{
		string message = "No appropriate files found in ";
		message+=path;
		log.println(message);
		// change back to original directory
		_chdir(buffer);
		return;
	}
	
	extractPairs(files, db, 0, 0, rankRange);
	// change back to original directory
	_chdir(buffer);
}
コード例 #3
0
ファイル: LogWriter.cpp プロジェクト: HaikuArchives/Cortex
// Logging thread function
int32 LogWriterLoggingThread(void* arg)
{
	LogWriter* obj = static_cast<LogWriter*>(arg);
	port_id port = obj->mPort;

	// event loop

	bool done = false;
	do
	{
		log_message msg;
		int32 what;
		status_t n_bytes = ::read_port(port, &what, &msg, sizeof(log_message));
		if (n_bytes > 0)
		{
			obj->HandleMessage((log_what) what, msg);
			if (LOG_QUIT == what) done = true;
		}
		else
		{
			fprintf(stderr, "LogWriter failed (%s) in ::read_port()!\n", strerror(n_bytes));
		}
	} while (!done);

	// got the "quit" message; now we're done
	return 0;
}
コード例 #4
0
LogWriter operator<<(LogWriter w, const QStringList &strList)
{
    w.write('[');
    for (int i = 0; i < strList.size(); ++i) {
        w.write(strList.at(i));
        if (i != strList.size() - 1)
            w.write(QLatin1String(", "));
    }
    w.write(']');
    return w;
}
コード例 #5
0
LogWriter operator<<(LogWriter w, const QSet<QString> &strSet)
{
    bool firstLoop = true;
    w.write('(');
    foreach (const QString &str, strSet) {
        if (firstLoop)
            firstLoop = false;
        else
            w.write(QLatin1String(", "));
        w.write(str);
    }
    w.write(')');
    return w;
}
コード例 #6
0
int _tmain(int argc, _TCHAR* argv[])
{
    if(argc == 2)
    {
        try
        {
            if(TSTRCMP(argv[1], TEXT("install")) == 0)
                WizardServiceProvider::GetInstance().Install();
            else if(TSTRCMP(argv[1], TEXT("uninstall")) == 0)
                WizardServiceProvider::GetInstance().Uninstall();
        }
        catch(Exception& error)
        {
            MessageBox(NULL, error.GetMessage().c_str(), TEXT("错误"), MB_OK|MB_ICONERROR);
        }
    }
    else
    {
        WizardServiceImpl& service = WizardServiceProvider::GetInstance();

        g_objLogWriter.Open(service.GetServicePath() + TEXT("Logs\\WizardService.log"));
        g_objLogWriter.Out(TEXT("///////////////////////////////////////\n"));
        g_objLogWriter.Out(TEXT("// Start Wizard Service\n"));
        g_objLogWriter.Out(TEXT("///////////////////////////////////////\n"));

        // 本地页面片服务
        WizardPageService objPageService;
        if(objPageService.Start() != NULL)
        {
            service.Register(&objPageService);
        }
        else
        {
            // startup local page service fail.
            g_objLogWriter.Out(TEXT(">> Error Startup Wizard Page Service\n"));
        }

        WizardVersionService objVersionService;
        if(objVersionService.Start() != NULL)
        {
            service.Register(&objVersionService);
        }
        else
        {
            // startup version control service fail.
            g_objLogWriter.Out(TEXT(">> Error Startup Wizard Version Service\n"));
        }

        g_objLogWriter.Out(TEXT("Service Dispatch...\n"));
        service.Dispatcher();

        g_objLogWriter.Close();
    }
    return 0;
}
コード例 #7
0
ファイル: log.cpp プロジェクト: magicminglee/c-log
bool logInit(LogLevel l, const char* modulename, const char* logdir, bool verbose) {
	if (access(logdir, 0) == -1) {
		if (mkdir(logdir, S_IRWXU) < 0) {
			fprintf(stderr, "%s create folder failed\n", logdir);
			return false;
		}
	}

	time_t now = time(&now);;
	struct tm vtm;
    localtime_r(&now, &vtm);
	char location_str[LogWriter::M_LOG_PATH_LEN] = {0};
	snprintf(location_str, LogWriter::M_LOG_PATH_LEN, "%s/%s.info.%d%02d%02d-%02d",logdir,modulename,1900+vtm.tm_year,vtm.tm_mon + 1,vtm.tm_mday,vtm.tm_hour);
	INFO_W.loginit(l, location_str, verbose);
	snprintf(location_str, LogWriter::M_LOG_PATH_LEN, "%s/%s.error.%d%02d%02d-%02d", logdir,modulename,1900+vtm.tm_year,vtm.tm_mon + 1,vtm.tm_mday,vtm.tm_hour);
	if(l > LL_WARNING)
		WARN_W.loginit(l, location_str, verbose);
	else
		WARN_W.loginit(LL_WARNING, location_str, verbose);
	return true;
}
コード例 #8
0
/** Process the file list and extract training pairs from each file.
@params files A list of SGF files to extract patterns from.
@params db The NNDatabase to store the training pairs in. 
NOTE: The files list should be full path names and files, e.g.
"c:\Docs\Cheese\Toe.txt" */
void Urgency3BPNGoTrainer::extractPairs(vector<string>& files, 
		NNDatabase* db, int movesFrom /*=0*/, int movesTo /*=0*/, const GoRankRange* rankRange /*=NULL*/) const
{	
	LogWriter log;
	log.println("Processing file list", goAdapter->getBPN().getTypeString());
	
	string message;
	string file;

	for(int i=0;i<files.size();i++)
	{
		message = "Reading: ";
		message+=files[i];
		log.println("Reading: "+files[i], goAdapter->getBPN().getTypeString());
		//file = path;
		//file+="\\";
		//file+=files[i];
		SGFReader sgf;
		if(!sgf.load(files[i]))
		{
			log.println("SGF failed to load");
			continue;
		}
		if(rankRange==NULL || rankRangeFilterSGF(sgf, *rankRange))
			extractTrainingPairs(&sgf, db, movesFrom, movesTo);
		else
		{
			message = "* Skipping - : ";
			message+=files[i];
			log.println(message);
		}
	}
	log.println("Finished processing file ", goAdapter->getBPN().getTypeString());
}
コード例 #9
0
const LogLevel::type LogLevel::fromString(const std::string& levelString,
    const LogWriter& logger)
{
  const std::map<const std::string, LogLevel::type>::const_iterator search =
      s_allLogLevels.find(levelString);
  if (search != s_allLogLevels.end()) {
    return search->second;
  }
  else {
    // keep unchanged
    return logger.getLogLevel();
  }
}
コード例 #10
0
ファイル: main.cpp プロジェクト: Atarity/Lightpack
    static void messageHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg)
    {
        static const LogWriter::Level s_msgType2Loglevel[] = {
            LogWriter::Debug, LogWriter::Warn, LogWriter::Critical, LogWriter::Fatal, LogWriter::Debug
        };
        Q_ASSERT(type >= 0 && type < sizeof(s_msgType2Loglevel)/sizeof(s_msgType2Loglevel[0]));
        Q_UNUSED(ctx);
        if (g_logWriter)
            g_logWriter->writeMessage(msg, s_msgType2Loglevel[type]);

        if (type == QtFatalMsg) {
            exit(LightpackApplication::QFatalMessageHandler_ErrorCode);
        }
    }
コード例 #11
0
ファイル: BPN.cpp プロジェクト: julianchurchill/Melkor
void BPN::completenessTest(NNDatabase& db)
{
	LogWriter log;
	string message;
	char buffer[50];

	log.println("Running training completeness test.");

	vector<Matrix<float> >& input = db.getTrainingInput();
	vector<Matrix<float> >& output = db.getTrainingOutput();
	int correct = 0;
	for(int i=0;i<input.size();i++)
	{
		getAnswer(input[i]);
		if(outputs[outputs.size()-1]==output[i])
			correct++;
		//delete bpnOutput;
		if(i%100==0)
		{
			log.print(".");
		}
	}

	log.print("\n");
	sprintf(buffer, "%d", correct);
	message+=buffer;
	message+= " correct out of ";
	sprintf(buffer, "%d", input.size());
	message+=buffer;
	log.println(message);
	int percent = ((float)correct/(float)input.size())*(float)100;
	sprintf(buffer, "%d", percent);
	message+=buffer;
	message+="% correct";
	log.println(message);
	log.println("Completeness test finished.");
}
コード例 #12
0
ファイル: SGFNode.cpp プロジェクト: julianchurchill/Melkor
/** @brief Print the property information for this node. Recursively look at
  * children also, but only the primary child - siblings are not looked at. */
void SGFNode::printInfo() const
{
	LogWriter log;
	set<SGFProperty, less<SGFProperty> >::const_iterator citer;
	citer = properties.begin();
	while(citer!=properties.end()) {
		log.print(citer->getName());
		log.print(" = ");
		vector<string> v = citer->getValues();
		for(int i=0;i<v.size();i++) {
			log.print(v.at(i));
			log.print(" ");
		}
		log.print("\n");
		citer++;
	}

	/** @todo Print info on siblings also... */
	if(child!=NULL)
		child->printInfo();
}
コード例 #13
0
/** Extract all training pairs from an SGF file using the given
SGFReader object and add them to the given NNDatabase.
@params sgf An SGFReader object to use to read the file it 
represents.
@params database The NNDatabase to store the training pairs in. */
void Urgency3BPNGoTrainer::extractTrainingPairs(SGFReader* sgf, NNDatabase* database,
			int movesFrom /*=0*/, int movesTo /*=0*/, int lookahead /*=0*/, bool quiet /*=false*/) const
{
	// at each step in sgf file, score current move with current urgency net
	// then score next move of same colour
	// if first move doesn't score at least 0.2 higher than second
	// add as training pairs:
	// 1. First move output should be second move score +0.2 (0.9 max)
	// 2. Second move output should be first move score -0.2 (0.1 min)

	LogWriter log;
	string message;
	//char buffer[50];

	if(movesFrom > movesTo)
	{
		log.println("Start move is greater than end move.");
		return;
	}

	vector<Move> moves;
	sgf->getTree().getAllPrimaryMoves(moves);
	if(moves.size()==0)
		return;

	// if file already in the database skip it
	if(!database->addSignature(sgf->getSignature()))
	{
		log.println("File already in database.");
		return;
	}

	int size = 19;
	string v;
	if(sgf->getBoardSize(v))
		size = atoi(v.c_str());
	if(size>19 || size<5) 
	{
		message = "Boardsize too small or large to handle: ";
		message+=v;
		log.println(message);
		return;
	}
	BoardStruct board(size);
	
	vector<Move> futureMoves;
	int moveNumber=0;
	
	string c;
	Matrix<float> currentInput(1, goAdapter->getBPN().getWeights()[0].getHeight());
	Matrix<float> nextInput(1, goAdapter->getBPN().getWeights()[0].getHeight());
	Matrix<float> output(1, 1);
	Matrix<float>* answers;
//	vector<Matrix<float> > temp(goAdapter->getBPN().getNumberOfLayers());
	vector<vector<float> > tv;
	tv.resize(1);
	tv[0].resize(1);
	// colour of new move
	int colour;
	
	//sgf->initBoard(board);
	board.clear();
	// add setup points
	setupBoardFromSGF(*sgf, board);
/*	vector<Move> props;
	if(sgf->getRootNode()->getEmptySetup(props))
	{
		for(int i=0;i<props.size();i++)
			board.setPoint(props[i].getX(), props[i].getY(), EMPTY, false);
	}
	if(sgf->getRootNode()->getBlackSetup(props))
	{
		for(int i=0;i<props.size();i++)
			board.setPoint(props[i].getX(), props[i].getY(), BLACK, false);
	}
	if(sgf->getRootNode()->getWhiteSetup(props))
	{
		for(int i=0;i<props.size();i++)
			board.setPoint(props[i].getX(), props[i].getY(), WHITE, false);
	} */

	SGFNode* nextNode = &(sgf->getRootNode());
	bool useThisMove = true;
	
	bool currentIsMoveA = true;
	bool getInputSuccess = false;

	// continue until a null node forces the loop to break
	while (true) {
		// check bounds if necessary
		if(movesTo!=0) {
			// use ply instead of individual moves
			if(moveNumber/2 >= movesTo) break;
			else if(moveNumber/2 < movesFrom) useThisMove = false;
			else useThisMove = true;
		}

		if(movesTo==0 || useThisMove) {
			nextNode = nextNode->getChild();
			if(nextNode==NULL)
				break;
			
			// determine colour of move	
			vector<string> vs;
			if (nextNode->getProperty(SGFProperty::blackMoveTag, vs)) {
				colour = BLACK;
				c = vs[0];
			}
			else if (nextNode->getProperty(SGFProperty::whiteMoveTag, vs)) {
				colour = WHITE;
				c = vs[0];
			}
			else break;
		
			// find our next move to compare with
			// check 
			futureMoves.clear();
			// NOTE: The first move returned by getLookaheadMoves() is
			// always the current one, so we need 2 lookahead moves
			nextNode->getLookaheadMoves(2, colour, futureMoves);
			if(futureMoves.size()==2 && Move::SGFToX(c)!=-1 && Move::SGFToY(c)!=-1
				&& futureMoves[1].getX()!=-1 && futureMoves[1].getY()!=-1) {
				// At each step in sgf file, score current move with current urgency net
				// then score next move of same colour
				// if first move doesn't score at least 0.2 higher than second
				// add as training pairs:
				// 1. First move output should be second move score +0.2 (0.9 max)
				// 2. Second move output should be first move score -0.2 (0.1 min)

				// get current move score
				goAdapter->getInput(Move::SGFToX(c), Move::SGFToY(c), board, currentInput, colour);
				goAdapter->getBPN().getAnswer(currentInput);
				answers = &(goAdapter->getBPN().getOutputs()[goAdapter->getBPN().getNumberOfLayers()-1]);
				float currentMoveScore = answers->getValue(0, 0);

				// get next move score
				goAdapter->getInput(futureMoves[1].getX(), futureMoves[1].getY(), board, nextInput, colour);
				goAdapter->getBPN().getAnswer(nextInput);
				answers = &(goAdapter->getBPN().getOutputs()[goAdapter->getBPN().getNumberOfLayers()-1]);
				float nextMoveScore = answers->getValue(0, 0);

				// if current scores higher than next move by 0.2
				// don't train otherwise do train
				if(currentMoveScore<=(nextMoveScore+0.2)) {
					if((nextMoveScore+0.2)>0.9)
						tv[0][0] = 0.9f;
					else
						tv[0][0] = nextMoveScore+0.2;
					output.setValues(tv);
					database->addTrainingPair(&currentInput, &output);

					if((currentMoveScore-0.2)<0.1)
						tv[0][0] = 0.1f;
					else
						tv[0][0] = currentMoveScore-0.2;
					output.setValues(tv);
					database->addTrainingPair(&nextInput, &output);
				}
			}
		} // end if(movesTo==0 || useThisMove)
		
		board.setPoint(Move::SGFToX(c), Move::SGFToY(c), colour);
		if(!quiet)
			log.print(".");
		moveNumber++;
		// save after every board position has been
		// analysed and moves extracted
		// database.save();
	} // end while(true)
	if(!quiet)
		log.print("\n");
	//database.save();
} // end extractTrainingPairs
コード例 #14
0
ファイル: log.cpp プロジェクト: gityf/log
bool log_close() {
    WARN_W.logclose();
    INFO_W.logclose();
    return true;
}
コード例 #15
0
LogWriter operator<<(LogWriter w, const char *str)
{
    w.write(str);
    return w;
}
コード例 #16
0
ファイル: BPN.cpp プロジェクト: julianchurchill/Melkor
/** Load a BPN network from the specified file.
Save version differences:
Version 0: Includes saveVersion, type, learningRate, momentum, epochsCompleted and weights.
Version 1: Adds lastPatternTest, patternsCompleted.
Version 2: Adds dynamicLearningRate, dynamicMomentum.
Version 3: Adds inputFieldShape.
@param f The filename to read this BPN network from. 
@param quiet An optional parameter to select level of text output, default is false.
@see BPN::save() */
bool BPN::load(string f, bool quiet /*=false*/)
{
	LogWriter log;
	string message = "Loading ";
	message+=f;
	if(!quiet)
		log.println(message);

	ifstream in(f.c_str(), ios::binary);

	if(!in)
	{
		message = "BPN: Could not load file: ";
		message+=f;
		LogWriter::printerr(message+"\n");
		return false;
	}

	this->filename = f;

	// read save version
	in.read(reinterpret_cast<char*>(&saveVersion), sizeof(int));
	if(in.fail()) 
	{
		LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
		return false;
	}

	// read type
	in.read(reinterpret_cast<char*>(&id), sizeof(int));
	if(in.fail()) 
	{
		LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
		return false;
	}


	// load learning rate
	in.read(reinterpret_cast<char*>(&learningRate), sizeof(float));
	if(in.fail()) 
	{
		LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
		return false;
	}

	// load momentum
	in.read(reinterpret_cast<char*>(&momentum), sizeof(float));
	if(in.fail()) 
	{
		LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
		return false;
	}

	// load the number of epochs this net has completed
	in.read(reinterpret_cast<char*>(&epochsCompleted), sizeof(int));
	if(in.fail()) 
	{
		LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
		return false;
	}

	// load number of layers

	// load weights as matrices including top row of each for bias weights
	int it = 0;
	in.read(reinterpret_cast<char*>(&it), sizeof(int));
	if(in.fail()) 
	{
		LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
		return false;
	}

	activationFunction.clear();
	weights.resize(it);
	biasWeights.resize(it);
	errors.resize(it);
	outputs.resize(it+1);
//	net.resize(it);
	// load layer sizes - width, height
	Matrix<float>* temp;
	for(int l=0;l<it;l++)
	{
		temp = Matrix<float>::load(in);
		if(temp==NULL)
		{
			LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
			return false;
		}

		//weights[l] = *temp;
		biasWeights[l].resize(temp->getWidth(), 1);
		weights[l].resize(temp->getWidth(), temp->getHeight()-1);
		for(int y=0;y<temp->getHeight();y++)
		{
			for(int x=0;x<temp->getWidth();x++)
			{
				// if this is the bias weight row
				if(y==0)
					biasWeights[l].setValue(x, 0, temp->getValue(x, 0));
				else
					weights[l].setValue(x, y-1, temp->getValue(x, y));
			}
		}
		delete temp;
		temp = NULL;
		activationFunction.push_back(SIGMOID);
	}

	weightsSize = weights.size();

	// load lastPatternTest and patternsCompleted
	if(saveVersion>0)
	{
		in.read(reinterpret_cast<char*>(&lastPatternTest), sizeof(double));
		if(in.fail()) 
		{
			LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
			return false;
		}
		in.read(reinterpret_cast<char*>(&patternsCompleted), sizeof(double));
		if(in.fail()) 
		{
			LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
			return false;
		}
		dynamicLearningRate = false;
		dynamicMomentum = false;
	}

	if(saveVersion>1)
	{
		in.read(reinterpret_cast<char*>(&dynamicLearningRate), sizeof(bool));
		if(in.fail()) 
		{
			LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
			return false;
		}
		in.read(reinterpret_cast<char*>(&dynamicMomentum), sizeof(bool));
		if(in.fail()) 
		{
			LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
			return false;
		}
	}

	if(saveVersion>2)
	{
		in.read(reinterpret_cast<char*>(&inputFieldShape), sizeof(int));
		if(in.fail()) 
		{
			LogWriter::printerr("Corrupt or incorrect version of .bpn file, aborting...\n", typeToString(id));
			return false;
		}
	}

	in.close();

	resetWeightChanges();
	
	return true;
}
コード例 #17
0
ファイル: BPN.cpp プロジェクト: julianchurchill/Melkor
/** Print useful information about this object. In this case,
output all the weights for each layer. */
void BPN::printInfo(bool printWeights /* = true */) const
{
	LogWriter log;
	char buffer[50];
	sprintf(buffer, "Filename: %s", filename.c_str());
	log.println(buffer);
	sprintf(buffer, "Save version: %d", saveVersion);
	log.println(buffer);
	sprintf(buffer, "Type: %s", typeToString(id));
	log.println(buffer);
	sprintf(buffer, "Learning rate: %*g", 7, learningRate);
	log.println(buffer);
	sprintf(buffer, "Momentum: %*g", 7, momentum);
	log.println(buffer);
	sprintf(buffer, "Epochs completed: %d", epochsCompleted);
	log.println(buffer);
	sprintf(buffer, "Patterns completed: %g", patternsCompleted);
	log.println(buffer);
	sprintf(buffer, "Last pattern test: %g", lastPatternTest);
	log.println(buffer);
	if(dynamicLearningRate)
		sprintf(buffer, "Dynamic learning rate: True");
	else
		sprintf(buffer, "Dynamic learning rate: False");
	log.println(buffer);
	if(dynamicMomentum)
		sprintf(buffer, "Dynamic momentum: True");
	else
		sprintf(buffer, "Dynamic momentum: False");
	log.println(buffer);

	if(inputFieldShape==IFS_SQUARE)
		log.println("Input field shape: IFS_SQUARE");
	else if(inputFieldShape==IFS_DIAMOND)
		log.println("Input field shape: IFS_DIAMOND");
	else
		log.println("Input field shape: UNKNOWN");

	// output neurons info
	sprintf(buffer, "Input neurons: %d", weights[0].getHeight());
	log.println(buffer);
	for(int i=1;i<weights.size();i++)
	{
		sprintf(buffer, "Hidden neurons(%d): %d", i-1, weights[i].getHeight());
		log.println(buffer);
	}
	sprintf(buffer, "Output neurons: %d", weights[weights.size()-1].getWidth());
	log.println(buffer);

	if(printWeights)
	{
		for(int i=0;i<weights.size();i++)
		{
			sprintf(buffer, "Weights for layer %d:", i);
			log.println(buffer);
			getWeights()[i].printInfo();
		}
		for(i=0;i<biasWeights.size();i++)
		{
			sprintf(buffer, "Bias weights for layer %d:", i);
			log.println(buffer);
			biasWeights[i].printInfo();
		}
	}

	// print rank test values
//	if(printTestResults)
//	{
//		log.print("Rank test values: ");
//		for(i=0;i<rankTestValue.size();i++)
//		{
//			sprintf(buffer, "%d", rankTestEpoch[i]);
//			message+=buffer;
//			message+="[";
//			sprintf(buffer, "%*g", 9, rankTestValue[i]);
//			message+=buffer;
//			message+="] ";
//			log.print(message);
//		}
//	}
	log.print("\n");
}
コード例 #18
0
LogWriter operator<<(LogWriter w, const QByteArray &byteArray)
{
    w.write(byteArray.data());
    return w;
}
コード例 #19
0
ファイル: main.cpp プロジェクト: Atarity/Lightpack
    Gestalt( gestaltSystemVersion, &version );
    bool endActivityRequired = false;
    if ( version >= 0x1090 ) {
      activity = [[NSProcessInfo processInfo] beginActivityWithOptions: NSActivityLatencyCritical reason:@"Prismatik is latency-critical app"];
      endActivityRequired = true;
      DEBUG_LOW_LEVEL << "Latency critical activity is started";
    }
#elif defined Q_OS_WIN
    // Mutex used by InnoSetup to detect that app is runnning.
    // http://www.jrsoftware.org/ishelp/index.php?topic=setup_appmutex
    HANDLE appMutex = CreateMutexW(NULL, FALSE, L"LightpackAppMutex");
#endif

    const QString appDirPath = getApplicationDirectoryPath(argv[0]);

    LogWriter logWriter;
    const int logInitResult = logWriter.initWith(appDirPath + "/Logs");
    if (logInitResult != LightpackApplication::OK_ErrorCode) {
        exit(logInitResult);
    }

    LogWriter::ScopedMessageHandler messageHandlerGuard(&logWriter);
    Q_UNUSED(messageHandlerGuard);

    LightpackApplication lightpackApp(argc, argv);
    lightpackApp.setLibraryPaths(QStringList(appDirPath + "/plugins"));
    lightpackApp.initializeAll(appDirPath);

    if (lightpackApp.isRunning())
    {
        lightpackApp.sendMessage("Application already running");
コード例 #20
0
LogWriter operator<<(LogWriter w, const QString &str)
{
    w.write(str);
    return w;
}