Introduce ways to toggle and tweak core Trace Event recording and logging

When toggling tile debugging in the Help>About, toggle Trace Event
recordning, too. Add a comment with an example of how to turn on
SAL_LOG overriding at the same place.

The following new messages from client to server are introduced:

traceeventrecording <start/stop>

    Starts or stops comphelper::TraceEvent recording.

sallogoverride <string>

    Overrides the SAL_LOG value, or stops overriding if no parameter
    or parameter is "default".

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I8b56c28cd99d39115cd796c44e5051d934d21a1f
Signed-off-by: Tor Lillqvist <tml@collabora.com>
This commit is contained in:
Tor Lillqvist 2021-04-21 17:42:52 +03:00 committed by Tor Lillqvist
parent 9ef32a3e38
commit eb9c580c36
4 changed files with 71 additions and 2 deletions

View file

@ -305,7 +305,9 @@ bool ChildSession::_handleInput(const char *buffer, int length)
tokens.equals(0, "removetextcontext") || tokens.equals(0, "removetextcontext") ||
tokens.equals(0, "dialogevent") || tokens.equals(0, "dialogevent") ||
tokens.equals(0, "completefunction")|| tokens.equals(0, "completefunction")||
tokens.equals(0, "formfieldevent")); tokens.equals(0, "formfieldevent") ||
tokens.equals(0, "traceeventrecording") ||
tokens.equals(0, "sallogoverride"));
if (tokens.equals(0, "clientzoom")) if (tokens.equals(0, "clientzoom"))
{ {
@ -457,6 +459,37 @@ bool ChildSession::_handleInput(const char *buffer, int length)
{ {
return formFieldEvent(buffer, length, tokens); return formFieldEvent(buffer, length, tokens);
} }
else if (tokens.equals(0, "traceeventrecording"))
{
if (tokens.size() > 0)
{
if (tokens.equals(1, "start"))
{
getLOKit()->setOption("traceeventrecording", "start");
LOG_INF("Profile zone tracing in this kit process turned on (might have been on all the time)");
}
else if (tokens.equals(1, "stop"))
{
getLOKit()->setOption("traceeventrecording", "stop");
LOG_INF("Profile zone tracing in this kit process turned off");
}
}
}
else if (tokens.equals(0, "sallogoverride"))
{
if (tokens.size() == 0 || tokens.equals(1, "default"))
{
getLOKit()->setOption("sallogoverride", nullptr);
}
else if (tokens.size() > 0 && tokens.equals(1, "off"))
{
getLOKit()->setOption("sallogoverride", "-WARN-INFO");
}
else if (tokens.size() > 0)
{
getLOKit()->setOption("sallogoverride", tokens[1].c_str());
}
}
else else
{ {
assert(false && "Unknown command token."); assert(false && "Unknown command token.");

View file

@ -26,6 +26,11 @@ L.Map.include({
} }
}, },
// Triple-clicking turns profiling on in the kit process for
// this document (it is already if the server is running with log level
// "trace"). Triple-clicking again turns it off. Etc.
_profilingRequestedToggle: false,
onFontSelect: function(e) { onFontSelect: function(e) {
var font = e.target.value; var font = e.target.value;
this.applyFont(font); this.applyFont(font);
@ -703,6 +708,19 @@ L.Map.include({
hammer.add(new Hammer.Tap({ taps: 3 })); hammer.add(new Hammer.Tap({ taps: 3 }));
hammer.on('tap', function() { hammer.on('tap', function() {
map._docLayer.toggleTileDebugMode(); map._docLayer.toggleTileDebugMode();
map._socket.sendMessage('traceeventrecording ' + (map._profilingRequestedToggle ? 'stop' : 'start'));
// 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 2) all warnings on plus SAL_INFO for sc.
//
// (Note that loolwsd sets the SAL_LOG environment variable to
// "-WARN-INFO", i.e. the default is that nothing is logged)
// map._socket.sendMessage('sallogoverride ' + (map._profilingRequestedToggle ? 'default' : '+WARN+INFO.sc'));
map._profilingRequestedToggle = !map._profilingRequestedToggle;
}); });
this.contentEl.style.width = w + 'px'; this.contentEl.style.width = w + 'px';

View file

@ -691,7 +691,10 @@ bool ClientSession::_handleInput(const char *buffer, int length)
docBroker->uploadAsToStorage(getId(), "", wopiFilename, true); docBroker->uploadAsToStorage(getId(), "", wopiFilename, true);
return true; return true;
} }
else if (tokens.equals(0, "dialogevent") || tokens.equals(0, "formfieldevent")) else if (tokens.equals(0, "dialogevent") ||
tokens.equals(0, "formfieldevent") ||
tokens.equals(0, "traceeventrecording") ||
tokens.equals(0, "sallogoverride"))
{ {
return forwardToChild(firstLine, docBroker); return forwardToChild(firstLine, docBroker);
} }

View file

@ -289,6 +289,15 @@ removesession <viewid>
privilege views cannot remove higher ones, eg. a readonly view privilege views cannot remove higher ones, eg. a readonly view
can't remove an editor. can't remove an editor.
traceeventrecording <start/stop>
Starts or stops comphelper::TraceEvent recording.
sallogoverride <string>
Overrides the SAL_LOG value, or stops overriding if no parameter
or parameter is "default".
server -> client server -> client
================ ================
@ -622,6 +631,12 @@ clipboardcontent:
<binary selection content> <binary selection content>
... ...
trace:
Followed by a number of lines consisting of Chrome Trace Event
formatted data recorded by the comphelper::TraceEvent API in the
core parts of the kit process.
parent -> child parent -> child
=============== ===============