Changeset 104750 in vbox for trunk/src/VBox/Main
- Timestamp:
- May 22, 2024 9:46:13 AM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp
r104748 r104750 1440 1440 1441 1441 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1442 1443 i_setLoggingLevel(data.strLoggingLevel); /* ignore errors here! */ 1444 1442 1445 HRESULT hrc = i_setDefaultMachineFolder(data.strDefaultMachineFolder); 1443 if (FAILED(hrc)) return hrc;1444 1445 hrc = i_setLoggingLevel(data.strLoggingLevel);1446 1446 if (FAILED(hrc)) return hrc; 1447 1447 … … 1667 1667 HRESULT SystemProperties::i_setLoggingLevel(const com::Utf8Str &aLoggingLevel) 1668 1668 { 1669 Utf8Str useLoggingLevel(aLoggingLevel); 1670 if (useLoggingLevel.isEmpty()) 1671 useLoggingLevel = VBOXSVC_LOG_DEFAULT; 1672 int vrc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), useLoggingLevel.c_str()); 1673 // If failed and not the default logging level - try to use the default logging level. 1674 if (RT_FAILURE(vrc)) 1675 { 1676 // If failed write message to the release log. 1677 LogRel(("Cannot set passed logging level=%s Error=%Rrc \n", useLoggingLevel.c_str(), vrc)); 1678 // If attempted logging level not the default one then try the default one. 1679 if (!useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT)) 1669 static const char s_szDefaultLevel[] = VBOXSVC_LOG_DEFAULT; 1670 const char *pszUseLoggingLevel = aLoggingLevel.isEmpty() || aLoggingLevel.equalsIgnoreCase(s_szDefaultLevel) 1671 ? s_szDefaultLevel : aLoggingLevel.c_str(); 1672 HRESULT hrc = S_OK; 1673 PRTLOGGER const pRelLog = RTLogRelGetDefaultInstance(); 1674 if (pRelLog) 1675 { 1676 int vrc = RTLogGroupSettings(pRelLog, pszUseLoggingLevel); 1677 if (RT_FAILURE(vrc)) 1680 1678 { 1681 vrc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), VBOXSVC_LOG_DEFAULT); 1682 // If failed report this to the release log. 1683 if (RT_FAILURE(vrc)) 1684 LogRel(("Cannot set default logging level Error=%Rrc \n", vrc)); 1679 LogRel(("Failed to set release logging level to '%s': %Rrc\n", pszUseLoggingLevel, vrc)); 1680 hrc = setErrorVrc(vrc, tr("RTLogGroupSettings failed: %Rrc (input: %s)"), vrc, pszUseLoggingLevel); 1681 1682 // If attempted logging level not the default one then use the default one. 1683 if (pszUseLoggingLevel != s_szDefaultLevel) 1684 { 1685 pszUseLoggingLevel = s_szDefaultLevel; 1686 vrc = RTLogGroupSettings(pRelLog, s_szDefaultLevel); 1687 if (RT_FAILURE(vrc)) 1688 LogRel(("Failed to set default release logging level: %Rrc\n", vrc)); 1689 } 1685 1690 } 1686 // On any failure - set default level as the one to be stored. 1687 useLoggingLevel = VBOXSVC_LOG_DEFAULT; 1688 } 1689 // Set to passed value or if default used/attempted (even if error condition) use empty string. 1690 m->strLoggingLevel = (useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT) ? "" : useLoggingLevel); 1691 return RT_SUCCESS(vrc) ? S_OK : E_FAIL; 1691 } 1692 1693 // Set to passed value or if default used/attempted (even if error condition) use empty string. 1694 if (pszUseLoggingLevel == s_szDefaultLevel) 1695 m->strLoggingLevel.setNull(); 1696 else 1697 m->strLoggingLevel = aLoggingLevel; 1698 1699 return hrc; 1692 1700 } 1693 1701
Note:
See TracChangeset
for help on using the changeset viewer.