本文整理匯總了C++中CloseLogFile函數的典型用法代碼示例。如果您正苦於以下問題:C++ CloseLogFile函數的具體用法?C++ CloseLogFile怎麽用?C++ CloseLogFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CloseLogFile函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: OpenLogFile
static sc_status
OpenLogFile(
sc_logging_info_t* log,
const char* filename)
{
static const char *replace = "w";
static const char *append = "a+";
const char *mode;
if (log && log->stream)
CloseLogFile(log);
if (filename == NULL)
filename = SC_DEFAULT_LOG_FILENAME;
size_t length = strlen(filename) + 1;
log->filename = scAllocate(log->session, length * sizeof(char));
snprintf(log->filename, length, "%s", filename);
mode = (log->flags & SC_LOG_APPEND) ? append : replace;
log->stream = fopen(log->filename, mode);
if (log->stream == NULL)
{
CloseLogFile(log);
return SC_INVALID_LOG_FILE;
}
return SC_SUCCESS;
}
示例2: main
/* 編譯從這開始 */
int main (int argc, char **argv)
{
int i;
//share_fs ();
CurrentHeap = &ProgramHeap;
argc--; argv++;
#if defined(_LF)
init_file_layout ();
init_memory_layout ();
#endif
CreateLogFile ();
#if 1
i = ParseCommandLine (argc, argv);
/* 初始化詞法分析器 */
SetupLexer ();
/* 按照配置文件設置基本類型和默認函數的屬性 */
SetupTypeSystem ();
for ( ; i < argc; i++ ) {
Compile (argv[i]);
}
#endif
CloseLogFile ();
return (ErrorCount != 0 ? -1 : 0);
}
示例3: pthread_mutex_lock
//-----------------------------------------------------------------------------
CmWebLog::~CmWebLog(void) {
pthread_mutex_lock(&WebLog_mutex); // yea, its mine
--RefCounter;
if (RefCounter <= 0)
CloseLogFile();
pthread_mutex_unlock(&WebLog_mutex);
}
示例4: CloseLogFile
HRESULT CTaksiLogFile::OpenLogFile( const TCHAR* pszFileName )
{
CloseLogFile();
if ( ! sg_Config.m_bDebugLog)
{
return HRESULT_FROM_WIN32(ERROR_CANCELLED);
}
m_File.AttachHandle( ::CreateFile( pszFileName, // file to create
GENERIC_WRITE, // open for writing
0, // do not share
NULL, // default security
OPEN_ALWAYS, // append existing else create
FILE_ATTRIBUTE_NORMAL, // normal file
NULL )); // no attr. template
if ( ! m_File.IsValidHandle())
{
HRESULT hRes = HRes_GetLastErrorDef( HRESULT_FROM_WIN32(ERROR_CANNOT_MAKE));
return hRes;
}
// Append to the end of the file if it exists
if ( GetLastError() == ERROR_ALREADY_EXISTS )
{
SetFilePointer( (HANDLE)m_File, GetFileSize((HANDLE)m_File, NULL), NULL, FILE_BEGIN );
}
return S_OK;
}
示例5: OpenLogFile
void Chapter1Test::Test1_8() {
ofstream fout;
OpenLogFile(fout,"test1_8.html","Problem 1.8: check if s2 is the rotation of s1");
bool expected(true);
TestBasic(fout, "", sol.prob1_8("", ""), expected);
expected = true;
TestBasic(fout, "abcde, cdeab", sol.prob1_8("abcde", "cdeab"), expected);
expected = true;
TestBasic(fout, "abcde, abcde", sol.prob1_8("abcde", "abcde"), expected);
expected = true;
TestBasic(fout, "abcdef, cdefab", sol.prob1_8("abcdef", "cdefab"), expected);
expected = false;
TestBasic(fout, "abcde, cdaeb", sol.prob1_8("abcde", "cdaeb"), expected);
expected = false;
TestBasic(fout, "abcde, abcdef", sol.prob1_8("abcde", "abcdef"), expected);
CloseLogFile(fout);
}
示例6: CloseLogFile
void CNtlLogSystem::RefreshLogFileFullName()
{
sSOURCE_INFO* pSourceInfo = NULL;
sLOG_FILE_INFO* pLogFileInfo = NULL;
std::map<DWORD, sSOURCE_INFO*>::iterator iterSource;
for (iterSource = m_mapSource.begin() ; m_mapSource.end() != iterSource ; iterSource++)
{
pSourceInfo = iterSource->second;
if (NULL != pSourceInfo)
{
std::map<CNtlString, sLOG_FILE_INFO*>::iterator iterLogFile;
for (iterLogFile = (pSourceInfo->mapLoggingFileInfo).begin() ; (pSourceInfo->mapLoggingFileInfo).end() != iterLogFile ; iterLogFile++)
{
pLogFileInfo = iterLogFile->second;
if (NULL != pLogFileInfo)
{
::EnterCriticalSection(&(pLogFileInfo->lock));
CloseLogFile(pLogFileInfo);
OpenLogFile(pLogFileInfo);
::LeaveCriticalSection(&(pLogFileInfo->lock));
}
}
}
}
}
示例7: OpenLogFile
void Chapter9Test::Test9_5() {
ofstream fout;
OpenLogFile(fout, "test9_5.html", "Problem 9.5: return all permutation of a string");
vector<string> ret;
string input;
// 1.
ret.clear();
input = "abc";
ret = sol.prob9_5(input);
TestDynamicArray(fout, input, ret, {"bca","acb","bac","abc","cab","cba"});
// 2.
ret.clear();
input = "ab";
ret = sol.prob9_5(input);
TestDynamicArray(fout, input, ret, {"ab","ba"});
// 3.
ret.clear();
input = "a";
ret = sol.prob9_5(input);
TestDynamicArray(fout, input, ret, {"a"});
// 4.
ret.clear();
input = "";
ret = sol.prob9_5(input);
TestDynamicArray(fout, input, ret, {""});
// 5.
ret.clear();
input = "abcd";
ret = sol.prob9_5(input);
TestDynamicArray(fout, input, ret, {"abcd","abdc","acbd","acdb","adbc","adcb","bacd","badc","bdac","bdca","bcad","bcda",\
"cabd","cadb","cbad","cbda","cdab","cdba","dabc","dacb","dbac","dbca","dcab","dcba"});
CloseLogFile(fout);
}
示例8: EVENT_USB_Device_Connect
/** Event handler for the library USB Connection event. */
void EVENT_USB_Device_Connect(void)
{
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
/* Close the log file so that the host has exclusive filesystem access */
CloseLogFile();
}
示例9: CrashError
//note to self: do try not to rely on this too much.
void __cdecl CrashError(const TCHAR *format, ...)
{
if(!format) return;
va_list arglist;
va_start(arglist, format);
String strOut = FormattedStringva(format, arglist);
OpenLogFile();
LogFile.WriteStr(TEXT("\r\nError: "));
LogFile.WriteAsUTF8(strOut);
LogFile.WriteStr(TEXT("\r\n"));
CloseLogFile();
OSMessageBoxva(format, arglist);
#if defined(_DEBUG) && defined(_WIN32)
if(bDebugBreak && OSDebuggerPresent())
ProgramBreak();
#endif
CriticalExit();
}
示例10: TraceCrashEnd
void STDCALL TraceCrashEnd()
{
String strStackTrace = TEXT("\r\nException Fault - Stack Trace:");
for(unsigned int i=0; i<TraceFuncList.Num(); i++)
{
if(i) strStackTrace << TEXT(" -> ");
if(!(i%10)) strStackTrace << TEXT("\r\n ");
strStackTrace << TraceFuncList[i];
}
if(TraceFuncList.Num() == MAX_STACK_TRACE)
strStackTrace << TEXT(" -> ...");
String strOut = FormattedString(TEXT("%s\r\n"), strStackTrace.Array());
OpenLogFile();
LogFile.WriteAsUTF8(strOut, strOut.Length());
LogFile.WriteAsUTF8(TEXT("\r\n"));
CloseLogFile();
OSMessageBox(TEXT("Error: Exception fault - More info in the log file.\r\n\r\nMake sure you're using the latest verison, otherwise send your log to [email protected]"));
TraceFuncList.Clear();
CriticalExit();
}
示例11: OpenLogFile
void Chapter2Test::Test2_1() {
ofstream fout;
OpenLogFile(fout,"test2_1.html","Problem 2.1: remove duplicate elements from a list");
ListNode *head(nullptr);
ListNode::GenerateListNode({}, 0, head);
ListNode *expected(nullptr);
sol.prob2_1(head);
TestLinkedList(fout, "", head, expected);
int A[] = {1,2,3,4};
ListNode::GenerateListNode(A, 4, head);
ListNode::GenerateListNode(A, 4, expected);
sol.prob2_1(head);
TestLinkedList(fout, "1->2->3->4#", head, expected);
int A1[] = {1,2,2,3,1,4,5,1,2,3,4,5,3,4,5}, B1[] = {1,2,3,4,5};
ListNode::GenerateListNode(A1, sizeof(A1)/sizeof(A1[0]), head);
ListNode::GenerateListNode(B1, sizeof(B1)/sizeof(B1[0]), expected);
stringstream ss;
ListNode::PrintListNode(head, ss);
sol.prob2_1(head);
TestLinkedList(fout, ss.str(), head, expected);
int A2[] = {1,1,1,1,1}, B2[] = {1};
ListNode::GenerateListNode(A2, sizeof(A2)/sizeof(A2[0]), head);
ListNode::GenerateListNode(B2, sizeof(B2)/sizeof(B2[0]), expected);
ss.str("");
ListNode::PrintListNode(head, ss);
sol.prob2_1(head);
TestLinkedList(fout, ss.str(), head, expected);
CloseLogFile(fout);
}
示例12: ExitLogger
void ExitLogger(void)
{
/* Trace */
RL_PRINT("Closing debug log file\n");
/*Close the log file */
CloseLogFile(fpdbg);
}
示例13: DeleteCriticalSection
/* static */
void Logger::Shutdown()
{
if (s_initialized)
{
DeleteCriticalSection(&s_critSec);
CloseLogFile();
s_initialized = false;
}
}
示例14: DllMain
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvreserved )
{
int Priority;
switch ( dwReason )
{
case DLL_THREAD_ATTACH:
break;
case DLL_PROCESS_ATTACH:
if ( !ClearAndGenerateLogFile( ) )
{
return false;
}
InitMainVariables( );
if ( SetPriorityClass( GetCurrentProcess( ), NORMAL_PRIORITY_CLASS ) == 0 )
{
Error( "Could not set Class Priority.\n" );
}
else
{
GlideMsg( OGL_LOG_SEPARATE );
GlideMsg( "Wrapper Class Priority of %d\n", NORMAL_PRIORITY_CLASS );
}
switch ( UserConfig.Priority )
{
case 0: Priority = THREAD_PRIORITY_HIGHEST; break;
case 1: Priority = THREAD_PRIORITY_ABOVE_NORMAL; break;
case 2: Priority = THREAD_PRIORITY_NORMAL; break;
case 3: Priority = THREAD_PRIORITY_BELOW_NORMAL; break;
case 4: Priority = THREAD_PRIORITY_LOWEST; break;
case 5: Priority = THREAD_PRIORITY_IDLE; break;
default: Priority = THREAD_PRIORITY_NORMAL; break;
}
if ( SetThreadPriority( GetCurrentThread(), Priority ) == 0 )
{
Error( "Could not set Thread Priority.\n" );
}
else
{
GlideMsg( "Wrapper Priority of %d\n", UserConfig.Priority );
GlideMsg( OGL_LOG_SEPARATE );
}
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
grGlideShutdown( );
CloseLogFile( );
break;
}
return TRUE;
}
示例15: GetLocalTime
void FileMedia::Write(ELogMessageType type, ELogMessageLevel nLevel, LPCTSTR pszDate, LPCTSTR pszTime, LPCTSTR pszThreadId, LPCTSTR pszThreadName, LPCTSTR pszModule, LPCTSTR pszMessage)
{
if (m_bNewFileDaily && m_wLogYear != 0)
{
SYSTEMTIME st;
GetLocalTime(&st);
if (st.wDay != m_wLogDay || st.wMonth != m_wLogMonth || st.wDay != m_wLogDay)
{
CloseLogFile();
OpenLogFile();
}
}
if (WaitForSingleObject(m_hMutex, 1000) == WAIT_TIMEOUT)
return;
// trying to restore access
if (m_hFile == INVALID_HANDLE_VALUE)
{
m_hFile = CreateFile(m_sFilename,
GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (m_hFile == INVALID_HANDLE_VALUE)
{
VERIFY(ReleaseMutex(m_hMutex));
return;
}
}
LONG dwDistanceToMoveHigh = 0; // Нужен, чтобы писать в файлы больше 4Гб
if (SetFilePointer(m_hFile, 0, &dwDistanceToMoveHigh, FILE_END) == INVALID_SET_FILE_POINTER
&& GetLastError() != NO_ERROR)
{
_RPT0(_CRT_ERROR, "FileMedia: Can't set file pointer");
m_hFile.Close();
VERIFY(ReleaseMutex(m_hMutex));
return;
}
CString output;
FormatLogMessage(type, nLevel, pszDate, pszTime, pszThreadId, pszThreadName, pszModule, pszMessage, output);
output += _T("\r\n");
CStringA outputA = output;
DWORD dwWritten;
// VERIFY(WriteFile(m_hFile, (LPCTSTR)output, (DWORD) output.size() * sizeof(TCHAR), &dwWritten, NULL));
VERIFY(WriteFile(m_hFile, (LPCSTR)outputA, (DWORD) outputA.GetLength() * sizeof(CHAR), &dwWritten, NULL));
if (m_bFlush)
VERIFY(FlushFileBuffers(m_hFile));
VERIFY(ReleaseMutex(m_hMutex));
}