blob: 20a0cc6ccc159ce576b831f08f8559cff580ccd0 (
plain)
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
|
#ifndef _WSX22_UTILS_LOGGER
#define _WSX22_UTILS_LOGGER
#define PREFIX_SIZE 6
typedef void (__cdecl *LogFunction)(const wchar_t* szText);
/**
* Universal Logger
*
* Singleton pattern based on
* http://www.codeproject.com/KB/threads/SingletonThreadSafety.aspx
*/
class MFLogger
{
public:
//static method that returns only instance of MFLogger
//////no thread safe so use it first time from only one thread (guaranted in mirfox)
static MFLogger *
getInstance() {
//initialized always from one thread
if (m_pOnlyOneInstance == NULL) {
if (m_pOnlyOneInstance == NULL) {
m_pOnlyOneInstance = new MFLogger();
}
}
return m_pOnlyOneInstance;
}
MFLogger();
void initLogger(LogFunction logFunction_p);
void set6CharsPrefix(const wchar_t* prefix);
void releaseLogger();
void log(const wchar_t* szText);
void log_p(const wchar_t* szText, ...);
void log_d(const wchar_t* szText);
void log_dp(const wchar_t* szText, ...);
private:
void log_int(const wchar_t* szText);
//holds one and only object of MySingleton
static MFLogger* m_pOnlyOneInstance;
wchar_t m_prefix[PREFIX_SIZE];
LogFunction logFunction;
CRITICAL_SECTION logCs;
};
#endif //#ifndef _WSX22_UTILS_LOGGER
|