예제 #1
0
int CloseFileStream(wofstream &myfile) {
	if (myfile.is_open()) {
		myfile.flush();
		myfile.close();
	}
	return status_ok;
}
예제 #2
0
int WriteFileRaw(wofstream &myfile, wstring resultData) {
	if (myfile.is_open()) {
		myfile << std::time(NULL) << L":" << resultData << endl;
		myfile.flush();
	} else
		return status_query_failed;
	return status_ok;
}
예제 #3
0
int OpenFileStream(wofstream &myfile, wstring fileName, bool recreate) {

	if (recreate)
		myfile.open(fileName, ios::out);
	else
		myfile.open(fileName, ios::out | ios::app);
	if (myfile.is_open()) {
		std::locale loc(std::locale::classic(), new std::codecvt_utf8<wchar_t>);
		myfile.imbue(loc);
		return status_ok;
	} else
		return status_io_error;
}
예제 #4
0
bool Logger::openStream(wstring & path)
{
	if(outLog)
	{
		outLog->flush();
		delete outLog;
	}
	outLog = new wofstream(path);
	return outLog!=NULL;
}
예제 #5
0
int WriteFileLog(wofstream &myfile, wstring data) {
	if (myfile.is_open()) {
		struct tm lt;

		time_t now_local = time(NULL);
		localtime_s(&lt, &now_local);

		wchar_t szBuf[2148] = L"";
		_snwprintf_s(szBuf, 2148, 2148, L"[%d-%02d-%02d %02d:%02d:%02d]: %s",
				lt.tm_year + 1900, lt.tm_mon + 1, lt.tm_mday, lt.tm_hour,
				lt.tm_min, lt.tm_sec, data.data());
		myfile << szBuf << endl;
#ifdef REC_TEST_CONSOLE
		wcout<< szBuf << endl;
#endif

		myfile.flush();
	} else
		return status_query_failed;
	return status_ok;
}
예제 #6
0
void Logger::log(bool onlyVerbose,const wchar_t* format, ...)
{
	if(!loggerOn||!outLog)return;
	if(onlyVerbose &!verbose)return;
	static wchar_t buffer[2048];
	va_list argptr;
	va_start(argptr, format);
	vswprintf(buffer, 2048, format, argptr);
	va_end(argptr);
	std::wcout << buffer << L"\n";
	(*outLog) << buffer << L"\n";
	outLog->flush();
};