xref: /qemu/qga/vss-win32/vss-debug.cpp (revision dcaaf2bf)
1 /*
2  * QEMU Guest Agent VSS debug declarations
3  *
4  * Copyright (C) 2023 Red Hat Inc
5  *
6  * Authors:
7  *  Konstantin Kostiuk <kkostiuk@redhat.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2 or later.
10  * See the COPYING file in the top-level directory.
11  */
12 
13 #include "qemu/osdep.h"
14 #include "vss-debug.h"
15 #include "vss-common.h"
16 
17 void qga_debug_internal(const char *funcname, const char *fmt, ...)
18 {
19     char user_string[512] = {0};
20     char full_string[640] = {0};
21 
22     va_list args;
23     va_start(args, fmt);
24     if (vsnprintf(user_string, _countof(user_string), fmt, args) <= 0) {
25         va_end(args);
26         return;
27     }
28 
29     va_end(args);
30 
31     if (snprintf(full_string, _countof(full_string),
32                  QGA_PROVIDER_NAME "[%lu]: %s %s\n",
33                  GetCurrentThreadId(), funcname, user_string) <= 0) {
34         return;
35     }
36 
37     OutputDebugString(full_string);
38     fputs(full_string, stderr);
39 }
40