blob: a9ee8f2d9761f6761194fa655cd9a6e93e59ab5d (
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
59
60
61
62
63
64
|
#pragma once
#include <whisperWindows.h>
#include <deque>
#include <unordered_set>
class AppState;
class DebugConsole
{
using eLogLevel = Whisper::eLogLevel;
struct Entry
{
eLogLevel level;
CStringA message;
HRESULT print( HANDLE hConsole, CString& tempString ) const;
};
CComAutoCriticalSection critSec;
std::deque<Entry> buffer;
CString tempString;
CHandle output;
inline void logSink( eLogLevel lvl, const char* message );
static void __stdcall logSinkStatic( void* context, eLogLevel lvl, const char* message );
static BOOL __stdcall consoleHandlerRoutine( DWORD dwCtrlType );
static DebugConsole* pGlobalInstance;
void windowClosed();
std::unordered_set<CButton*> checkboxes;
CStringA tempStringA;
void log( eLogLevel lvl, const char* pszFormat, va_list args );
public:
HRESULT initialize( eLogLevel level = eLogLevel::Debug );
~DebugConsole();
HRESULT show();
HRESULT hide();
bool isVisible() const { return output; }
void addCheckbox( CButton& cb );
void removeCheckbox( CButton& cb );
static void logMessage( eLogLevel lvl, const char* pszFormat, va_list args );
};
class ConsoleCheckbox
{
CButton control;
DebugConsole* console = nullptr;
public:
HRESULT initialize( HWND dialog, int idc, AppState& state );
void click();
~ConsoleCheckbox()
{
if( nullptr != console )
console->removeCheckbox( control );
}
void ensureChecked();
};
|