Revision | b950dddc8e8f2034edadbee282fae8bedb2c8a92 (tree) |
---|---|
Time | 2018-04-01 16:34:34 |
Author | Kazuhiro Fujieda <fujieda@user...> |
Commiter | Kazuhiro Fujieda |
Improve debug logging
@@ -6,7 +6,7 @@ | ||
6 | 6 | #include <ObjBase.h> |
7 | 7 | |
8 | 8 | #ifdef DEBUG_IME |
9 | -#define DebugLog(fmt, ...) CUtils::Log(fmt, __VA_ARGS__) | |
9 | +#define DebugLog(fmt, ...) CUtils::Log(_T(__FUNCTION__ ## ": " ## fmt), __VA_ARGS__) | |
10 | 10 | #else |
11 | 11 | #define DebugLog(fmt, ...) |
12 | 12 | #endif |
@@ -34,14 +34,14 @@ void TSFHandler::InitSink() | ||
34 | 34 | return; |
35 | 35 | HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); |
36 | 36 | if (FAILED(hr)) { |
37 | - DebugLog(_T("CoInitializeEx failed.")); | |
37 | + DebugLog("CoInitializeEx failed."); | |
38 | 38 | return; |
39 | 39 | } |
40 | 40 | if (hr == S_FALSE) |
41 | 41 | CoUninitialize(); |
42 | 42 | ITfThreadMgr *thread; |
43 | 43 | if (FAILED(CoCreateInstance(CLSID_TF_ThreadMgr, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&thread)))) { |
44 | - DebugLog(_T("CoCreateInstance for ThreadMgr failed.")); | |
44 | + DebugLog("CoCreateInstance for ThreadMgr failed."); | |
45 | 45 | return; |
46 | 46 | } |
47 | 47 | TSFHandler *tsfh = new TSFHandler(); |
@@ -49,12 +49,12 @@ void TSFHandler::InitSink() | ||
49 | 49 | tsfh->m_ThreadMgr = thread; |
50 | 50 | ITfSource *src; |
51 | 51 | if (FAILED(thread->QueryInterface(&src))) { |
52 | - DebugLog(_T("ThreadMgr->QueryInterface failed.")); | |
52 | + DebugLog("ThreadMgr->QueryInterface failed."); | |
53 | 53 | goto fail; |
54 | 54 | } |
55 | 55 | DWORD cookie; |
56 | 56 | if (FAILED(src->AdviseSink(IID_ITfThreadMgrEventSink, static_cast<ITfThreadMgrEventSink *>(tsfh), &cookie))) { |
57 | - DebugLog(_T("Souece->AdviseSink failed.")); | |
57 | + DebugLog("Souece->AdviseSink failed."); | |
58 | 58 | src->Release(); |
59 | 59 | goto fail; |
60 | 60 | } |
@@ -95,37 +95,37 @@ STDMETHODIMP_(ULONG) TSFHandler::Release() | ||
95 | 95 | // ITfThreadMgrEventSink |
96 | 96 | STDMETHODIMP TSFHandler::OnInitDocumentMgr(ITfDocumentMgr *) |
97 | 97 | { |
98 | - DebugLog(_T("OnInitDocumentMgr")); | |
98 | + DebugLog("OnInitDocumentMgr"); | |
99 | 99 | return S_OK; |
100 | 100 | } |
101 | 101 | |
102 | 102 | STDMETHODIMP TSFHandler::OnPopContext(ITfContext *) |
103 | 103 | { |
104 | - DebugLog(_T("OnPopContext")); | |
104 | + DebugLog("OnPopContext"); | |
105 | 105 | return S_OK; |
106 | 106 | } |
107 | 107 | |
108 | 108 | STDMETHODIMP TSFHandler::OnPushContext(ITfContext *) |
109 | 109 | { |
110 | - DebugLog(_T("OnPushContext")); | |
110 | + DebugLog("OnPushContext"); | |
111 | 111 | return S_OK; |
112 | 112 | } |
113 | 113 | |
114 | 114 | STDMETHODIMP TSFHandler::OnSetFocus(ITfDocumentMgr *docMgr, ITfDocumentMgr *) |
115 | 115 | { |
116 | - DebugLog(_T("OnSetFocus")); | |
116 | + DebugLog("OnSetFocus"); | |
117 | 117 | if (docMgr == nullptr) |
118 | 118 | return S_OK; |
119 | 119 | if (m_Cookie != TF_INVALID_COOKIE) { |
120 | 120 | ITfSource *src; |
121 | 121 | if (FAILED(m_Context->QueryInterface(&src))) { |
122 | - DebugLog(_T("Context->QueryInterface:0 failed.")); | |
122 | + DebugLog("Context->QueryInterface:0 failed."); | |
123 | 123 | return S_OK; |
124 | 124 | } |
125 | 125 | HRESULT hr = src->UnadviseSink(m_Cookie); |
126 | 126 | src->Release(); |
127 | 127 | if (FAILED(hr)) { |
128 | - DebugLog(_T("Source->UnadviceThink failed.")); | |
128 | + DebugLog("Source->UnadviceThink failed."); | |
129 | 129 | return S_OK; |
130 | 130 | } |
131 | 131 | m_Context->Release(); |
@@ -134,20 +134,20 @@ STDMETHODIMP TSFHandler::OnSetFocus(ITfDocumentMgr *docMgr, ITfDocumentMgr *) | ||
134 | 134 | } |
135 | 135 | ITfContext *cxt; |
136 | 136 | if (FAILED(docMgr->GetTop(&cxt))) { |
137 | - DebugLog(_T("DocumentMgr->GetTop failed.")); | |
137 | + DebugLog("DocumentMgr->GetTop failed."); | |
138 | 138 | return S_OK; |
139 | 139 | } |
140 | 140 | if (cxt == nullptr) { |
141 | - DebugLog(_T("ITfContext is null.")); | |
141 | + DebugLog("ITfContext is null."); | |
142 | 142 | return S_OK; |
143 | 143 | } |
144 | 144 | ITfSource *src; |
145 | 145 | if (FAILED(cxt->QueryInterface(&src))) { |
146 | - DebugLog(_T("Context->QueryInterface:1 failed.")); | |
146 | + DebugLog("Context->QueryInterface:1 failed."); | |
147 | 147 | goto fail; |
148 | 148 | } |
149 | 149 | if (FAILED(src->AdviseSink(IID_ITfTextEditSink, static_cast<ITfTextEditSink *>(this), &m_Cookie))) { |
150 | - DebugLog(_T("Source->AdviseSink(ITfTextEditSink) failed.")); | |
150 | + DebugLog("Source->AdviseSink(ITfTextEditSink) failed."); | |
151 | 151 | src->Release(); |
152 | 152 | goto fail; |
153 | 153 | } |
@@ -161,32 +161,32 @@ fail: | ||
161 | 161 | |
162 | 162 | STDMETHODIMP TSFHandler::OnUninitDocumentMgr(ITfDocumentMgr *) |
163 | 163 | { |
164 | - DebugLog(_T("OnUninitDocumentMgr")); | |
164 | + DebugLog("OnUninitDocumentMgr"); | |
165 | 165 | return S_OK; |
166 | 166 | } |
167 | 167 | |
168 | 168 | STDMETHODIMP TSFHandler::OnEndEdit(ITfContext *cxt, TfEditCookie, ITfEditRecord *) |
169 | 169 | { |
170 | - DebugLog(_T("OnEndEdit")); | |
170 | + DebugLog("OnEndEdit"); | |
171 | 171 | ITfContextComposition *comp; |
172 | 172 | if (FAILED(cxt->QueryInterface(&comp))) { |
173 | - DebugLog(_T("Context->QueryInterface(ITfContextComposition) failed.")); | |
173 | + DebugLog("Context->QueryInterface(ITfContextComposition) failed."); | |
174 | 174 | return S_OK; |
175 | 175 | } |
176 | 176 | IEnumITfCompositionView *enumCompView; |
177 | 177 | if (FAILED(comp->EnumCompositions(&enumCompView))) { |
178 | - DebugLog(_T("ContextComposition->EnumCompositions failed.")); | |
178 | + DebugLog("ContextComposition->EnumCompositions failed."); | |
179 | 179 | goto fail; |
180 | 180 | } |
181 | 181 | ITfCompositionView *view; |
182 | 182 | ULONG fetched; |
183 | 183 | HRESULT hr = enumCompView->Next(1, &view, &fetched); |
184 | 184 | if (FAILED(hr)) { |
185 | - DebugLog(_T("EnumCompositions->Next failed.")); | |
185 | + DebugLog("EnumCompositions->Next failed."); | |
186 | 186 | enumCompView->Release(); |
187 | 187 | goto fail; |
188 | 188 | } |
189 | - DebugLog(_T("EnumComposition->Next succeeded. fetched=%d"), fetched); | |
189 | + DebugLog("EnumComposition->Next succeeded. fetched=%d", fetched); | |
190 | 190 | if (fetched) { |
191 | 191 | if (!m_CompositionState) |
192 | 192 | CXkeymacsDll::SetIMEState(true); |