Simplify debug-log code
[git-cheetah/kirill.git] / common / debug.c
blob04efa7cef158a3891e4bc5df06c5008e5786184d
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 debug_git_fp = fopen("C:/git_shell_ext_debug.txt", "a+");
12 #else
13 debug_git_fp = fopen("/tmp/git-cheetah-plugin.log", "a+");
14 #endif
17 /* Check again in case the above debug_git_set_file failed. */
18 if (debug_git_fp)
20 va_list params;
21 char buffer[1024];
22 int length = 0;
24 va_start(params, format);
25 length = vsnprintf(buffer, sizeof(buffer), format, params);
26 va_end(params);
27 fwrite(buffer, sizeof(char), length, debug_git_fp);
28 fputc('\n', debug_git_fp);
29 fflush(debug_git_fp);
33 void debug_git_mbox(char *format, ...)
35 va_list params;
36 char buffer[1024];
38 va_start(params, format);
39 vsnprintf(buffer, sizeof(buffer), format, params);
40 va_end(params);
41 message_box(buffer);