Changeset 93220 in vbox for trunk/src/VBox
- Timestamp:
- Jan 13, 2022 11:45:40 AM (3 years ago)
- Location:
- trunk/src/VBox/Additions/x11/VBoxClient
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h
r93115 r93220 33 33 34 34 int VBClLogCreate(const char *pszLogFile); 35 void VBClLogSetLogPrefix(const char *pszPrefix); 35 36 void VBClLogDestroy(void); 36 37 … … 107 108 extern VBCLSERVICE g_SvcDisplayDRM; 108 109 extern VBCLSERVICE g_SvcDisplaySVGA; 110 extern VBCLSERVICE g_SvcDisplaySVGASession; 109 111 extern VBCLSERVICE g_SvcDragAndDrop; 110 112 extern VBCLSERVICE g_SvcHostVersion; -
trunk/src/VBox/Additions/x11/VBoxClient/logging.cpp
r93115 r93220 34 34 static uint32_t g_uHistoryFileTime = RT_SEC_1DAY; /* Max 1 day per file. */ 35 35 static uint64_t g_uHistoryFileSize = 100 * _1M; /* Max 100MB per file. */ 36 37 /** Custom log prefix (to be set externally). */ 38 static char *g_pszCustomLogPrefix; 36 39 37 40 extern unsigned g_cRespawn; … … 244 247 } 245 248 249 static DECLCALLBACK(size_t) vbClLogPrefixCb(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser) 250 { 251 size_t cbPrefix = 0; 252 253 RT_NOREF(pLogger); 254 RT_NOREF(pvUser); 255 256 if (g_pszCustomLogPrefix) 257 { 258 cbPrefix = RT_MIN(strlen(g_pszCustomLogPrefix), cchBuf); 259 memcpy(pchBuf, g_pszCustomLogPrefix, cbPrefix); 260 } 261 262 return cbPrefix; 263 } 264 246 265 /** 247 266 * Creates the default release logger outputting to the specified file. … … 259 278 /* Create release logger (stdout + file). */ 260 279 static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES; 261 RTUINT fFlags = RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME ;280 RTUINT fFlags = RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME | RTLOGFLAGS_PREFIX_CUSTOM; 262 281 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) 263 282 fFlags |= RTLOGFLAGS_USECRLF; … … 273 292 RTLogRelSetDefaultInstance(g_pLoggerRelease); 274 293 294 rc = RTLogSetCustomPrefixCallback(g_pLoggerRelease, vbClLogPrefixCb, NULL); 295 if (RT_FAILURE(rc)) 296 VBClLogError("unable to register custom log prefix callback\n"); 297 275 298 /* Explicitly flush the log in case of VBOXSERVICE_RELEASE_LOG=buffered. */ 276 299 RTLogFlush(g_pLoggerRelease); … … 281 304 282 305 /** 306 * Set custom log prefix. 307 * 308 * @param pszPrefix Custom log prefix string. 309 */ 310 void VBClLogSetLogPrefix(const char *pszPrefix) 311 { 312 g_pszCustomLogPrefix = (char *)pszPrefix; 313 } 314 315 /** 283 316 * Destroys the currently active logging instance. 284 317 */
Note:
See TracChangeset
for help on using the changeset viewer.