Changeset 69987 in vbox
- Timestamp:
- Dec 7, 2017 4:02:40 PM (7 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
r69779 r69987 334 334 335 335 336 /** 337 * Logs a verbose message. 338 * 339 * @param pszFormat The message text. 340 * @param ... Format arguments. 341 */ 342 void VGSvcLog(const char *pszFormat, ...) 343 { 344 #ifdef DEBUG 345 int rc = RTCritSectEnter(&g_csLog); 346 if (RT_SUCCESS(rc)) 347 { 348 #endif 349 va_list args; 350 va_start(args, pszFormat); 351 char *psz = NULL; 352 RTStrAPrintfV(&psz, pszFormat, args); 353 va_end(args); 354 355 AssertPtr(psz); 356 LogRel(("%s", psz)); 357 358 RTStrFree(psz); 359 #ifdef DEBUG 360 RTCritSectLeave(&g_csLog); 361 } 362 #endif 363 } 364 365 366 /** 367 * Destroys the currently active logging instance. 368 */ 336 369 void VGSvcLogDestroy(void) 337 370 { … … 415 448 416 449 /** 417 * Displays a verbose message. 450 * Displays a verbose message based on the currently 451 * set global verbosity level. 418 452 * 419 453 * @param iLevel Minimum log level required to display this message. … … 425 459 if (iLevel <= g_cVerbosity) 426 460 { 427 #ifdef DEBUG 428 int rc = RTCritSectEnter(&g_csLog); 429 if (RT_SUCCESS(rc)) 430 { 431 #endif 432 va_list args; 433 va_start(args, pszFormat); 434 char *psz = NULL; 435 RTStrAPrintfV(&psz, pszFormat, args); 436 va_end(args); 437 438 AssertPtr(psz); 439 LogRel(("%s", psz)); 440 441 RTStrFree(psz); 442 #ifdef DEBUG 443 RTCritSectLeave(&g_csLog); 444 } 445 #endif 461 va_list args; 462 va_start(args, pszFormat); 463 464 VGSvcLog(pszFormat, args); 465 466 va_end(args); 446 467 } 447 468 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h
r69500 r69987 185 185 extern void VGSvcVerbose(unsigned iLevel, const char *pszFormat, ...); 186 186 extern int VGSvcLogCreate(const char *pszLogFile); 187 extern void VGSvcLog(const char *pszFormat, ...); 187 188 extern void VGSvcLogDestroy(void); 188 189 extern int VGSvcArgUInt32(int argc, char **argv, const char *psz, int *pi, uint32_t *pu32, -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceTimeSync.cpp
r69953 r69987 131 131 /** Whether to set the time when the VM was restored. */ 132 132 static bool g_fTimeSyncSetOnRestore = true; 133 /** The logging verbosity. 134 * This uses the global verbosity level by default. */ 135 static unsigned g_uTimeSyncVerbosity = 0; 133 136 134 137 /** Current error count. Used to knowing when to bitch and when not to. */ … … 158 161 static DECLCALLBACK(int) vgsvcTimeSyncPreInit(void) 159 162 { 163 /* Use global verbosity as default. */ 164 g_uTimeSyncVerbosity = g_cVerbosity; 165 160 166 #ifdef VBOX_WITH_GUEST_PROPS 161 167 /** @todo Merge this function with vgsvcTimeSyncOption() to generalize … … 219 225 g_fTimeSyncSetOnRestore = !!value; 220 226 } 221 227 if ( RT_SUCCESS(rc) 228 || rc == VERR_NOT_FOUND) 229 { 230 uint32_t value; 231 rc = VGSvcReadPropUInt32(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/VBoxService/--timesync-verbosity", 232 &value, 0, 255); 233 if (RT_SUCCESS(rc)) 234 g_uTimeSyncVerbosity = (unsigned)value; 235 } 222 236 VbglR3GuestPropDisconnect(uGuestPropSvcClientID); 223 237 } … … 230 244 return VINF_SUCCESS; 231 245 #endif 246 } 247 248 249 /** 250 * Displays a verbose message based on the currently 251 * set timesync verbosity level. 252 * 253 * @param iLevel Minimum log level required to display this message. 254 * @param pszFormat The message text. 255 * @param ... Format arguments. 256 */ 257 static void vgsvcTimeSyncLog(unsigned iLevel, const char *pszFormat, ...) 258 { 259 if (iLevel <= g_uTimeSyncVerbosity) 260 { 261 va_list args; 262 va_start(args, pszFormat); 263 264 VGSvcLog(pszFormat, args); 265 266 va_end(args); 267 } 232 268 } 233 269 … … 336 372 337 373 if (GetSystemTimeAdjustment(&g_dwWinTimeAdjustment, &g_dwWinTimeIncrement, &g_bWinTimeAdjustmentDisabled)) 338 VGSvcVerbose(3, "vgsvcTimeSyncInit: Initially %ld (100ns) units per %ld (100 ns) units interval, disabled=%d\n",339 g_dwWinTimeAdjustment, g_dwWinTimeIncrement, g_bWinTimeAdjustmentDisabled ? 1 : 0);374 vgsvcTimeSyncLog(3, "vgsvcTimeSyncInit: Initially %ld (100ns) units per %ld (100 ns) units interval, disabled=%d\n", 375 g_dwWinTimeAdjustment, g_dwWinTimeIncrement, g_bWinTimeAdjustmentDisabled ? 1 : 0); 340 376 else 341 377 { … … 394 430 } 395 431 396 VGSvcVerbose(3, "vgsvcTimeSyncAdjust: Drift=%lldms\n", RTTimeSpecGetMilli(pDrift));397 VGSvcVerbose(3, "vgsvcTimeSyncAdjust: OrgTA=%ld, CurTA=%ld, NewTA=%ld, DiffNew=%ld, DiffMax=%ld\n",398 g_dwWinTimeAdjustment, dwWinTimeAdjustment, dwWinNewTimeAdjustment, dwDiffNew, dwDiffMax);432 vgsvcTimeSyncLog(3, "vgsvcTimeSyncAdjust: Drift=%lldms\n", RTTimeSpecGetMilli(pDrift)); 433 vgsvcTimeSyncLog(3, "vgsvcTimeSyncAdjust: OrgTA=%ld, CurTA=%ld, NewTA=%ld, DiffNew=%ld, DiffMax=%ld\n", 434 g_dwWinTimeAdjustment, dwWinTimeAdjustment, dwWinNewTimeAdjustment, dwDiffNew, dwDiffMax); 399 435 if (SetSystemTimeAdjustment(dwWinNewTimeAdjustment, FALSE /* Periodic adjustments enabled. */)) 400 436 { … … 421 457 { 422 458 if (g_cVerbosity >= 1) 423 VGSvcVerbose(1, "vgsvcTimeSyncAdjust: adjtime by %RDtimespec\n", pDrift);459 vgsvcTimeSyncLog(1, "vgsvcTimeSyncAdjust: adjtime by %RDtimespec\n", pDrift); 424 460 g_cTimeSyncErrors = 0; 425 461 return true; … … 445 481 return; 446 482 if (SetSystemTimeAdjustment(0, TRUE /* Periodic adjustments disabled. */)) 447 VGSvcVerbose(3, "vgsvcTimeSyncCancelAdjust: Windows Time Adjustment is now disabled.\n");483 vgsvcTimeSyncLog(3, "vgsvcTimeSyncCancelAdjust: Windows Time Adjustment is now disabled.\n"); 448 484 else if (g_cTimeSyncErrors++ < 10) 449 485 VGSvcError("vgsvcTimeSyncCancelAdjust: SetSystemTimeAdjustment(,disable) failed, error=%u\n", GetLastError()); … … 475 511 char sz[64]; 476 512 RTTIME Time; 477 VGSvcVerbose(1, "time set to %s\n", RTTimeToString(RTTimeExplode(&Time, &NewGuestTime), sz, sizeof(sz)));513 vgsvcTimeSyncLog(1, "time set to %s\n", RTTimeToString(RTTimeExplode(&Time, &NewGuestTime), sz, sizeof(sz))); 478 514 #ifdef DEBUG 479 515 RTTIMESPEC Tmp; 480 516 if (g_cVerbosity >= 3) 481 VGSvcVerbose(3, " now %s\n", RTTimeToString(RTTimeExplode(&Time, RTTimeNow(&Tmp)), sz, sizeof(sz)));517 vgsvcTimeSyncLog(3, " now %s\n", RTTimeToString(RTTimeExplode(&Time, RTTimeNow(&Tmp)), sz, sizeof(sz))); 482 518 #endif 483 519 } … … 556 592 && idNewSession != g_idTimeSyncSession) 557 593 { 558 VGSvcVerbose(3, "vgsvcTimeSyncWorker: The VM session ID changed, forcing resync.\n");594 vgsvcTimeSyncLog(3, "vgsvcTimeSyncWorker: The VM session ID changed, forcing resync.\n"); 559 595 g_idTimeSyncSession = idNewSession; 560 596 TimeSyncSetThreshold = 0; … … 577 613 if (g_cVerbosity >= 3) 578 614 { 579 VGSvcVerbose(3, "vgsvcTimeSyncWorker: Host: %s (MinAdjust: %RU32 ms)\n",580 RTTimeToString(RTTimeExplode(&Time, &HostNow), sz, sizeof(sz)), MinAdjust);581 VGSvcVerbose(3, "vgsvcTimeSyncWorker: Guest: - %s => %RDtimespec drift\n",582 RTTimeToString(RTTimeExplode(&Time, &GuestNow), sz, sizeof(sz)), &Drift);615 vgsvcTimeSyncLog(3, "vgsvcTimeSyncWorker: Host: %s (MinAdjust: %RU32 ms)\n", 616 RTTimeToString(RTTimeExplode(&Time, &HostNow), sz, sizeof(sz)), MinAdjust); 617 vgsvcTimeSyncLog(3, "vgsvcTimeSyncWorker: Guest: - %s => %RDtimespec drift\n", 618 RTTimeToString(RTTimeExplode(&Time, &GuestNow), sz, sizeof(sz)), &Drift); 583 619 } 584 620 … … 605 641 int64_t cNsHostDelta = RTTimeSpecGetNano(&HostNow) - RTTimeSpecGetNano(&HostLast); 606 642 if ((uint64_t)RT_ABS(cNsHostDelta) > RT_NS_1HOUR / 2) 607 VGSvcVerbose(0, "vgsvcTimeSyncWorker: Radical host time change: %'RI64ns (HostNow=%RDtimespec HostLast=%RDtimespec)\n",608 cNsHostDelta, &HostNow, &HostLast);643 vgsvcTimeSyncLog(0, "vgsvcTimeSyncWorker: Radical host time change: %'RI64ns (HostNow=%RDtimespec HostLast=%RDtimespec)\n", 644 cNsHostDelta, &HostNow, &HostLast); 609 645 } 610 646 else … … 613 649 break; 614 650 } 615 VGSvcVerbose(3, "vgsvcTimeSyncWorker: %RDtimespec: latency too high (%RDtimespec, max %ums) sleeping 1s\n",616 &GuestNow, &GuestElapsed, g_cMsTimeSyncMaxLatency);651 vgsvcTimeSyncLog(3, "vgsvcTimeSyncWorker: %RDtimespec: latency too high (%RDtimespec, max %ums) sleeping 1s\n", 652 &GuestNow, &GuestElapsed, g_cMsTimeSyncMaxLatency); 617 653 RTThreadSleep(1000); 618 654 } while (--cTries > 0);
Note:
See TracChangeset
for help on using the changeset viewer.