explorer: write debug log to temp dir
[git-cheetah/kirill.git] / common / debug.c
blob9bd6da1f3522ffcd8f60afdf0c8f49d836945ffe
1 #include "git-compat-util.h"
2 #include "systeminfo.h"
3 #include "debug.h"
5 static FILE *debug_git_fp = NULL;
7 void debug_git(char * format, ...)
9 if (!debug_git_fp) {
10 #ifdef _WIN32
11 WCHAR path[MAX_PATH];
12 GetTempPathW(MAX_PATH, path);
13 wcsncat(path, L"git_shell_ext_debug.txt", MAX_PATH);
14 debug_git_fp = _wfopen(path, L"a+");
15 #else
16 debug_git_fp = fopen("/tmp/git-cheetah-plugin.log", "a+");
17 #endif
20 /* Check again in case the above debug_git_set_file failed. */
21 if (debug_git_fp)
23 va_list params;
24 char buffer[1024];
25 int length = 0;
27 va_start(params, format);
28 length = vsnprintf(buffer, sizeof(buffer), format, params);
29 va_end(params);
30 fwrite(buffer, sizeof(char), length, debug_git_fp);
31 fputc('\n', debug_git_fp);
32 fflush(debug_git_fp);
36 void debug_git_mbox(char *format, ...)
38 va_list params;
39 char buffer[1024];
41 va_start(params, format);
42 vsnprintf(buffer, sizeof(buffer), format, params);
43 va_end(params);
44 message_box(buffer);