-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathVerboseLogFile.cpp
More file actions
65 lines (50 loc) · 1.24 KB
/
VerboseLogFile.cpp
File metadata and controls
65 lines (50 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "stdafx.h"
#include "Verboselogfile.h"
#include "SettingsStorage.h"
VerboseLogFile::VerboseLogFile(void)
{
m_hFile = INVALID_HANDLE_VALUE;
m_bInitialized = false;
}
VerboseLogFile::~VerboseLogFile(void)
{
}
bool VerboseLogFile::Init()
{
ATLASSERT(INVALID_HANDLE_VALUE == m_hFile);
if (m_hFile != INVALID_HANDLE_VALUE)
CloseHandle(m_hFile);
m_hFile = CreateFile((LPCTSTR)SettingsStorage::GetStorage().GetVerboseLogfile(),GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE != m_hFile)
{
SetEndOfFile(m_hFile);
return true;
}
return false;
}
void VerboseLogFile::Log(LPCTSTR pszText, int iLen)
{
ATLASSERT(m_bInitialized);
DWORD dummy;
if (INVALID_HANDLE_VALUE != m_hFile)
WriteFile(m_hFile, pszText, iLen, &dummy, NULL);
}
void VerboseLogFile::Close()
{
if (INVALID_HANDLE_VALUE != m_hFile)
{
CloseHandle(m_hFile);
m_hFile = INVALID_HANDLE_VALUE;
}
}
VerboseLogFile& VerboseLogFile::GetLogFile()
{
static VerboseLogFile s_Log;
if (!s_Log.m_bInitialized)
{
s_Log.m_bInitialized = true;
s_Log.Init();
}
return s_Log;
}