• R/O
  • HTTP
  • SSH
  • HTTPS

xkeymacs: Commit


Commit MetaInfo

Revisionb950dddc8e8f2034edadbee282fae8bedb2c8a92 (tree)
Time2018-04-01 16:34:34
AuthorKazuhiro Fujieda <fujieda@user...>
CommiterKazuhiro Fujieda

Log Message

Improve debug logging

Change Summary

Incremental Difference

--- a/xkeymacsdll/TSFHandler.cpp
+++ b/xkeymacsdll/TSFHandler.cpp
@@ -6,7 +6,7 @@
66 #include <ObjBase.h>
77
88 #ifdef DEBUG_IME
9-#define DebugLog(fmt, ...) CUtils::Log(fmt, __VA_ARGS__)
9+#define DebugLog(fmt, ...) CUtils::Log(_T(__FUNCTION__ ## ": " ## fmt), __VA_ARGS__)
1010 #else
1111 #define DebugLog(fmt, ...)
1212 #endif
@@ -34,14 +34,14 @@ void TSFHandler::InitSink()
3434 return;
3535 HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
3636 if (FAILED(hr)) {
37- DebugLog(_T("CoInitializeEx failed."));
37+ DebugLog("CoInitializeEx failed.");
3838 return;
3939 }
4040 if (hr == S_FALSE)
4141 CoUninitialize();
4242 ITfThreadMgr *thread;
4343 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.");
4545 return;
4646 }
4747 TSFHandler *tsfh = new TSFHandler();
@@ -49,12 +49,12 @@ void TSFHandler::InitSink()
4949 tsfh->m_ThreadMgr = thread;
5050 ITfSource *src;
5151 if (FAILED(thread->QueryInterface(&src))) {
52- DebugLog(_T("ThreadMgr->QueryInterface failed."));
52+ DebugLog("ThreadMgr->QueryInterface failed.");
5353 goto fail;
5454 }
5555 DWORD cookie;
5656 if (FAILED(src->AdviseSink(IID_ITfThreadMgrEventSink, static_cast<ITfThreadMgrEventSink *>(tsfh), &cookie))) {
57- DebugLog(_T("Souece->AdviseSink failed."));
57+ DebugLog("Souece->AdviseSink failed.");
5858 src->Release();
5959 goto fail;
6060 }
@@ -95,37 +95,37 @@ STDMETHODIMP_(ULONG) TSFHandler::Release()
9595 // ITfThreadMgrEventSink
9696 STDMETHODIMP TSFHandler::OnInitDocumentMgr(ITfDocumentMgr *)
9797 {
98- DebugLog(_T("OnInitDocumentMgr"));
98+ DebugLog("OnInitDocumentMgr");
9999 return S_OK;
100100 }
101101
102102 STDMETHODIMP TSFHandler::OnPopContext(ITfContext *)
103103 {
104- DebugLog(_T("OnPopContext"));
104+ DebugLog("OnPopContext");
105105 return S_OK;
106106 }
107107
108108 STDMETHODIMP TSFHandler::OnPushContext(ITfContext *)
109109 {
110- DebugLog(_T("OnPushContext"));
110+ DebugLog("OnPushContext");
111111 return S_OK;
112112 }
113113
114114 STDMETHODIMP TSFHandler::OnSetFocus(ITfDocumentMgr *docMgr, ITfDocumentMgr *)
115115 {
116- DebugLog(_T("OnSetFocus"));
116+ DebugLog("OnSetFocus");
117117 if (docMgr == nullptr)
118118 return S_OK;
119119 if (m_Cookie != TF_INVALID_COOKIE) {
120120 ITfSource *src;
121121 if (FAILED(m_Context->QueryInterface(&src))) {
122- DebugLog(_T("Context->QueryInterface:0 failed."));
122+ DebugLog("Context->QueryInterface:0 failed.");
123123 return S_OK;
124124 }
125125 HRESULT hr = src->UnadviseSink(m_Cookie);
126126 src->Release();
127127 if (FAILED(hr)) {
128- DebugLog(_T("Source->UnadviceThink failed."));
128+ DebugLog("Source->UnadviceThink failed.");
129129 return S_OK;
130130 }
131131 m_Context->Release();
@@ -134,20 +134,20 @@ STDMETHODIMP TSFHandler::OnSetFocus(ITfDocumentMgr *docMgr, ITfDocumentMgr *)
134134 }
135135 ITfContext *cxt;
136136 if (FAILED(docMgr->GetTop(&cxt))) {
137- DebugLog(_T("DocumentMgr->GetTop failed."));
137+ DebugLog("DocumentMgr->GetTop failed.");
138138 return S_OK;
139139 }
140140 if (cxt == nullptr) {
141- DebugLog(_T("ITfContext is null."));
141+ DebugLog("ITfContext is null.");
142142 return S_OK;
143143 }
144144 ITfSource *src;
145145 if (FAILED(cxt->QueryInterface(&src))) {
146- DebugLog(_T("Context->QueryInterface:1 failed."));
146+ DebugLog("Context->QueryInterface:1 failed.");
147147 goto fail;
148148 }
149149 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.");
151151 src->Release();
152152 goto fail;
153153 }
@@ -161,32 +161,32 @@ fail:
161161
162162 STDMETHODIMP TSFHandler::OnUninitDocumentMgr(ITfDocumentMgr *)
163163 {
164- DebugLog(_T("OnUninitDocumentMgr"));
164+ DebugLog("OnUninitDocumentMgr");
165165 return S_OK;
166166 }
167167
168168 STDMETHODIMP TSFHandler::OnEndEdit(ITfContext *cxt, TfEditCookie, ITfEditRecord *)
169169 {
170- DebugLog(_T("OnEndEdit"));
170+ DebugLog("OnEndEdit");
171171 ITfContextComposition *comp;
172172 if (FAILED(cxt->QueryInterface(&comp))) {
173- DebugLog(_T("Context->QueryInterface(ITfContextComposition) failed."));
173+ DebugLog("Context->QueryInterface(ITfContextComposition) failed.");
174174 return S_OK;
175175 }
176176 IEnumITfCompositionView *enumCompView;
177177 if (FAILED(comp->EnumCompositions(&enumCompView))) {
178- DebugLog(_T("ContextComposition->EnumCompositions failed."));
178+ DebugLog("ContextComposition->EnumCompositions failed.");
179179 goto fail;
180180 }
181181 ITfCompositionView *view;
182182 ULONG fetched;
183183 HRESULT hr = enumCompView->Next(1, &view, &fetched);
184184 if (FAILED(hr)) {
185- DebugLog(_T("EnumCompositions->Next failed."));
185+ DebugLog("EnumCompositions->Next failed.");
186186 enumCompView->Release();
187187 goto fail;
188188 }
189- DebugLog(_T("EnumComposition->Next succeeded. fetched=%d"), fetched);
189+ DebugLog("EnumComposition->Next succeeded. fetched=%d", fetched);
190190 if (fetched) {
191191 if (!m_CompositionState)
192192 CXkeymacsDll::SetIMEState(true);
Show on old repository browser