Bug 1657197 - Support enabling MOZ_LOG profilermarkers mirroring at runtime. r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D152166
This commit is contained in:
Paul Adenot 2022-07-20 13:25:33 +00:00
Родитель a61c54713b
Коммит 8c285223e3
4 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -378,6 +378,11 @@ function updateLogModules() {
activeLogModules.push("sync");
}
} catch (e) {}
try {
if (Services.prefs.getBoolPref("logging.config.profilermarkers")) {
activeLogModules.push("profilermarkers");
}
} catch (e) {}
let children = Services.prefs.getBranch("logging.").getChildList("");
@ -444,6 +449,8 @@ function setLogModules() {
// XXX: append is not yet supported.
} else if (module == "sync") {
Services.prefs.setBoolPref("logging.config.sync", true);
} else if (module == "profilermarkers") {
Services.prefs.setBoolPref("logging.config.profilermarkers", true);
} else {
let lastColon = module.lastIndexOf(":");
let key = module.slice(0, lastColon);

Просмотреть файл

@ -23,6 +23,7 @@ static const char kLoggingPrefClearOnStartup[] =
static const char kLoggingPrefLogFile[] = "logging.config.LOG_FILE";
static const char kLoggingPrefAddTimestamp[] = "logging.config.add_timestamp";
static const char kLoggingPrefSync[] = "logging.config.sync";
static const char kLoggingPrefMarkers[] = "logging.config.profilermarkers";
namespace mozilla {
@ -82,6 +83,9 @@ static void LoadPrefValue(const char* aName) {
} else if (prefName.EqualsLiteral(kLoggingPrefSync)) {
bool sync = Preferences::GetBool(aName, false);
LogModule::SetIsSync(sync);
} else if (prefName.EqualsLiteral(kLoggingPrefMarkers)) {
bool enableMarkers = Preferences::GetBool(aName, false);
LogModule::SetRecordMarkers(enableMarkers);
}
return;
}

Просмотреть файл

@ -520,6 +520,8 @@ class LogModuleManager {
void SetIsSync(bool aIsSync) { mIsSync = aIsSync; }
void SetRecordMarkers(bool aRecordMarkers) { mAddProfilerMarker = aRecordMarkers; }
void SetAddTimestamp(bool aAddTimestamp) { mAddTimestamp = aAddTimestamp; }
detail::LogFile* OpenFile(bool aShouldAppend, uint32_t aFileNum,
@ -812,6 +814,10 @@ void LogModule::SetIsSync(bool aIsSync) {
sLogModuleManager->SetIsSync(aIsSync);
}
void LogModule::SetRecordMarkers(bool aRecordMarkers) {
sLogModuleManager->SetRecordMarkers(aRecordMarkers);
}
// This function is defined in gecko_logger/src/lib.rs
// We mirror the level in rust code so we don't get forwarded all of the
// rust logging and have to create an LogModule for each rust component.

Просмотреть файл

@ -119,6 +119,12 @@ class LogModule {
*/
static void SetIsSync(bool aIsSync);
/**
* @param aRecordMarkers If we should add Firefox Profiler markers for each
* log entry.
*/
static void SetRecordMarkers(bool aRecordMarkers);
/**
* Indicates whether or not the given log level is enabled.
*/