[Libreoffice-commits] online.git: 2 commits - configure.ac loleaflet/dist loleaflet/main.js loleaflet/src loolwsd.xml.in wsd/FileServer.cpp wsd/LOOLWSD.cpp
Pranav Kant
pranavk at collabora.co.uk
Thu Dec 15 11:34:43 UTC 2016
configure.ac | 4 +++-
loleaflet/dist/loleaflet.html | 1 +
loleaflet/main.js | 8 ++++++++
loleaflet/src/map/Map.js | 22 ++++++++++------------
loolwsd.xml.in | 2 ++
wsd/FileServer.cpp | 4 ++++
wsd/LOOLWSD.cpp | 1 +
7 files changed, 29 insertions(+), 13 deletions(-)
New commits:
commit 73842dd307d0f7579ef5f456e380ab703d6e2c0d
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Dec 15 15:30:16 2016 +0530
Uncomment these console output statements
... as these are now printed only when compiled with
--enable-debug, so they shouldn't be polluting the release build.
Change-Id: I3169fb39cea298b001a4d576632a1634ff35e004
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index aebefe0..c22a9df 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -740,13 +740,13 @@ L.Map = L.Evented.extend({
},
_activate: function () {
- // console.log('_activate:');
+ console.debug('_activate:');
clearTimeout(vex.timer);
if (!this._active) {
// Only activate when we are connected.
if (this._socket.connected()) {
- // console.log(' sending useractive');
+ console.debug('sending useractive');
this._socket.sendMessage('useractive');
this._active = true;
this._docLayer._onMessage('invalidatetiles: EMPTY', null);
@@ -766,12 +766,11 @@ L.Map = L.Evented.extend({
},
_dim: function() {
- // console.log('_dim:');
+ console.debug('_dim:');
if (!this._socket.connected()) {
return;
}
- // console.log(' cont');
this._active = false;
clearTimeout(vex.timer);
@@ -794,7 +793,7 @@ L.Map = L.Evented.extend({
var map = this;
options.$vex.bind('click.vex', function(e) {
- // console.log('click.vex function');
+ console.debug('_dim: click.vex function');
return map._activate();
});
options.$vex.append(options.$vexOverlay);
@@ -808,12 +807,12 @@ L.Map = L.Evented.extend({
vex.setupBodyClassName(options.$vex);
this._doclayer && this._docLayer._onMessage('textselection:', null);
- // console.log(' sending userinactive');
+ console.debug('_dim: sending userinactive');
this._socket.sendMessage('userinactive');
},
_dimIfInactive: function () {
- // console.log('_dimIfInactive: diff=' + (Date.now() - map.lastActiveTime));
+ console.debug('_dimIfInactive: diff=' + (Date.now() - this.lastActiveTime));
if ((Date.now() - this.lastActiveTime) >= 1 * 60 * 1000) { // Dim 10 minutes after last user activity
this._dim();
} else {
@@ -822,7 +821,7 @@ L.Map = L.Evented.extend({
},
_startInactiveTimer: function () {
- // console.log('_startInactiveTimer:');
+ console.debug('_startInactiveTimer:');
clearTimeout(vex.timer);
var map = this;
vex.timer = setTimeout(function() {
@@ -831,7 +830,7 @@ L.Map = L.Evented.extend({
},
_deactivate: function () {
- // console.log('_deactivate:');
+ console.debug('_deactivate:');
clearTimeout(vex.timer);
if (!this._active || vex.dialogID > 0) {
@@ -840,7 +839,7 @@ L.Map = L.Evented.extend({
this._active = false;
this._docLayer && this._docLayer._onMessage('textselection:', null);
if (this._socket.connected()) {
- // console.log(' sending userinactive');
+ console.debug('_deactivate: sending userinactive');
this._socket.sendMessage('userinactive');
}
@@ -873,10 +872,9 @@ L.Map = L.Evented.extend({
},
_onGotFocus: function () {
- // console.log('_onGotFocus:');
+ console.debug('_onGotFocus:');
if (!this._loaded) { return; }
- // console.log(' cont');
var doclayer = this._docLayer;
if (doclayer) {
// we restore the old cursor position by a small delay, so that if the user clicks
commit 39dd5018e255ad529b409218cff983690700d70d
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Dec 15 15:26:54 2016 +0530
browser console logging depending on loleaflet_logging prop.
loleaflet_logging defaults to true with compiled with
--enable-debug otherwise false.
Browser will print additional debug info when this property is
set to true.
Change-Id: Id9fabf134bd8d19fa1a09ca8c0987df46d4f1a4c
diff --git a/configure.ac b/configure.ac
index fd0b0f6..5655aa0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,6 +109,7 @@ ENABLE_DEBUG=
LOOLWSD_LOGLEVEL="warning"
LOOLWSD_LOG_TO_FILE="false"
LOOLWSD_LOGFILE="/var/log/loolwsd.log"
+LOLEAFLET_LOGGING="false"
debug_msg="secure mode: product build"
if test "$enable_debug" = "yes"; then
AC_DEFINE([ENABLE_DEBUG],1,[Whether to compile in some extra debugging support code and disable some security pieces])
@@ -116,6 +117,7 @@ if test "$enable_debug" = "yes"; then
LOOLWSD_LOGLEVEL="trace"
LOOLWSD_LOG_TO_FILE="true"
LOOLWSD_LOGFILE="/tmp/loolwsd.log"
+ LOLEAFLET_LOGGING="true"
debug_msg="low security debugging mode"
else
AC_DEFINE([ENABLE_DEBUG],0,[Whether to compile in some extra debugging support code and disable some security pieces])
@@ -123,6 +125,7 @@ fi
AC_SUBST(ENABLE_DEBUG)
AC_SUBST(LOOLWSD_LOGLEVEL)
AC_SUBST(LOOLWSD_LOG_TO_FILE)
+AC_SUBST(LOLEAFLET_LOGGING)
if test -n "$with_logfile" ; then
LOOLWSD_LOGFILE="$with_logfile"
@@ -324,4 +327,3 @@ echo " \$ make run # to start loolwsd
fi
dnl vim:set shiftwidth=4 softtabstop=4 expandtab:
-
diff --git a/loleaflet/dist/loleaflet.html b/loleaflet/dist/loleaflet.html
index b154b08..d619c84 100644
--- a/loleaflet/dist/loleaflet.html
+++ b/loleaflet/dist/loleaflet.html
@@ -70,6 +70,7 @@
window.host = '%HOST%';
window.access_token = '%ACCESS_TOKEN%';
window.access_token_ttl = '%ACCESS_TOKEN_TTL%';
+ window.loleaflet_logging = '%LOLEAFLET_LOGGING%';
</script>
<script src="/loleaflet/%VERSION%/branding.js"></script> <!-- logo onclick handler -->
<script src="/loleaflet/%VERSION%/bundle.js"></script>
diff --git a/loleaflet/main.js b/loleaflet/main.js
index d9f8da1..ac359b5 100644
--- a/loleaflet/main.js
+++ b/loleaflet/main.js
@@ -1,3 +1,11 @@
+// If not debug, don't print anything on the console
+if (loleaflet_logging !== 'true') {
+ var methods = ['warn', 'info', 'debug', 'trace', 'log', 'assert', 'time', 'timeEnd'];
+ for (var i = 0; i < methods.length; i++) {
+ console[methods[i]] = function() {};
+ }
+}
+
// Include our main css file
require('./main.css');
diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index 0df6a01..c9547e3 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -33,6 +33,8 @@
</file>
</logging>
+ <loleaflet_logging desc="Logging in the browser console" default="@LOLEAFLET_LOGGING@">@LOLEAFLET_LOGGING@</loleaflet_logging>
+
<trace desc="Dump commands and notifications for replay" enable="true">
<path desc="Output file path" compress="true">/tmp/looltrace.gz</path>
<filter>
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 8f1f1fe..f74f80f 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -261,6 +261,10 @@ void FileServerRequestHandler::preprocessFile(HTTPServerRequest& request, HTTPSe
Poco::replaceInPlace(preprocess, std::string("%HOST%"), host);
Poco::replaceInPlace(preprocess, std::string("%VERSION%"), std::string(LOOLWSD_VERSION_HASH));
+ const auto& config = Application::instance().config();
+ const auto loleafletLogging = config.getString("loleaflet_logging", "false");
+ Poco::replaceInPlace(preprocess, std::string("%LOLEAFLET_LOGGING%"), loleafletLogging);
+
response.setContentType("text/html");
response.setContentLength(preprocess.length());
response.setChunkedTransferEncoding(false);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index fbdc975..33d70c1 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1557,6 +1557,7 @@ void LOOLWSD::initialize(Application& self)
{ "loleaflet_html", "loleaflet.html" },
{ "logging.color", "true" },
{ "logging.level", "trace" },
+ { "loleaflet_logging", "false" },
{ "ssl.enable", "true" },
{ "ssl.termination", "true" },
{ "ssl.cert_file_path", LOOLWSD_CONFIGDIR "/cert.pem" },
More information about the Libreoffice-commits
mailing list