Show verbose feedback when toggling log level and Trace Event generation

Sadly I had to use a global variable to access the actual contents of
the Help>About window as being displayed in its key event handler. If
somebody can figure out the correct clean way to do it, be my
guest. (Look for the app.ExpertlyTrickForLOAbout.)

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I88582e490d566d127d60226e045535e12c172e9c
This commit is contained in:
Tor Lillqvist 2021-06-30 12:43:59 +03:00 committed by Tor Lillqvist
parent 4f0f7d6123
commit 91486ce5d6
2 changed files with 33 additions and 8 deletions

View file

@ -249,6 +249,8 @@ m4_ifelse(MOBILEAPP,[true],
<div id="lokit-version"></div>
m4_ifelse(MOBILEAPP,[],[<div id="os-info" style="text-align:center"></div>])
<div id="slow-proxy"></div>
<p id="log-level-state">
<p id="trace-event-state">
<p>Copyright © _YEAR_, VENDOR.</p>
</div>

View file

@ -708,10 +708,23 @@ L.Map.include({
// so there is nothing more verbose. But presumably it is different
// in production setups.
app.socket.sendMessage('loggingleveloverride '
+ (app.socket.threadLocalLoggingLevelToggle ? 'default' : 'verbose'));
app.socket.threadLocalLoggingLevelToggle = !app.socket.threadLocalLoggingLevelToggle;
var newLogLevel = (app.socket.threadLocalLoggingLevelToggle ? 'verbose' : 'default');
app.socket.sendMessage('loggingleveloverride ' + newLogLevel);
var logLevelInformation = newLogLevel;
if (newLogLevel === 'default')
logLevelInformation = 'default (from loolwsd.xml)';
else if (newLogLevel === 'verbose')
logLevelInformation = 'most verbose (from loolwsd.xml)';
else if (newLogLevel === 'terse')
logLevelInformation = 'least verbose (from loolwsd.xml)';
else
logLevelInformation = newLogLevel;
$(app.ExpertlyTrickForLOAbout.contentEl).find('#log-level-state').html('Log level: ' + logLevelInformation);
} else if (event.key === 't') {
// T turns Trace Event recording on in the Kit process
// for this document, as long as loolwsd is running with the
@ -719,9 +732,12 @@ L.Map.include({
// turns it off.
if (app.socket.enableTraceEventLogging) {
app.socket.sendMessage('traceeventrecording '
+ (app.socket.traceEventRecordingToggle ? 'stop' : 'start'));
app.socket.traceEventRecordingToggle = !app.socket.traceEventRecordingToggle;
app.socket.sendMessage('traceeventrecording '
+ (app.socket.traceEventRecordingToggle ? 'start' : 'stop'));
$(app.ExpertlyTrickForLOAbout.contentEl).find('#trace-event-state').html('Trace Event generation: ' + (app.socket.traceEventRecordingToggle ? 'ON' : 'OFF'));
// Just as a test, uncomment this to toggle SAL_WARN and
// SAL_INFO selection between two states: 1) the default
// as directed by the SAL_LOG environment variable, and
@ -731,9 +747,7 @@ L.Map.include({
// to "-WARN-INFO", i.e. the default is that nothing is
// logged from core.)
// app.socket.sendMessage('sallogoverride ' + (app.socket.traceEventRecordingToggle ? 'default' : '+WARN+INFO.sc'));
app.socket.traceEventRecordingToggle = !app.socket.traceEventRecordingToggle;
// app.socket.sendMessage('sallogoverride ' + (app.socket.traceEventRecordingToggle ? '+WARN+INFO.sc' : 'default'));
}
}
};
@ -759,6 +773,12 @@ L.Map.include({
this.contentEl.style.width = w + 'px';
// FIXME: When we remove vex this needs to be cleaned up.
// It is hard to access the value of "this" in this afterOpen
// function in the handler function. Use a global variable until
// somebody figures out a better way.
app.ExpertlyTrickForLOAbout = this;
$(window).bind('keyup.vex', handler);
// workaround for https://github.com/HubSpot/vex/issues/43
$('.vex-overlay').css({ 'pointer-events': 'none'});
@ -770,6 +790,9 @@ L.Map.include({
touchGesture._hammer.on('tripletap', L.bind(touchGesture._onTripleTap, touchGesture));
}
map.focus();
// Unset the global variable, see comment above.
app.ExpertlyTrickForLOAbout = undefined;
// asyncTraceEvent.finish();
}
});