vss-debug.cpp 938 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #include "qemu/osdep.h"
  13. #include "vss-debug.h"
  14. #include "vss-common.h"
  15. void qga_debug_internal(const char *funcname, const char *fmt, ...)
  16. {
  17. char user_string[512] = {0};
  18. char full_string[640] = {0};
  19. va_list args;
  20. va_start(args, fmt);
  21. if (vsnprintf(user_string, _countof(user_string), fmt, args) <= 0) {
  22. va_end(args);
  23. return;
  24. }
  25. va_end(args);
  26. if (snprintf(full_string, _countof(full_string),
  27. QGA_PROVIDER_NAME "[%lu]: %s %s\n",
  28. GetCurrentThreadId(), funcname, user_string) <= 0) {
  29. return;
  30. }
  31. OutputDebugString(full_string);
  32. fputs(full_string, stderr);
  33. }