Skip to content

Commit

Permalink
Merge pull request #557 from peuter/logging
Browse files Browse the repository at this point in the history
enable/disable console logs via url parameter
  • Loading branch information
ChristianMayer committed Apr 16, 2017
2 parents 92c604c + 0de46cf commit b7e6bad
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
11 changes: 11 additions & 0 deletions doc/manual/de/config/url-params.rst
Expand Up @@ -201,3 +201,14 @@ Browser-Console (öffnen mit F12) ``downloadLog()`` ein gibt und mit *enter* bes
Da die Log-Dateien in Echtzeit abgespielt werden, empfiehlt es sich die Laufzeit möglichst kurz zu halten.
Eine Log-Datei die 30 Minuten oder mehr läuft bis das Problem zu sehen ist, wird die Fehlerbehebung
erschweren, da der Entwickler diese ggf. sehr oft abspielen muss während der Fehleranalyse und -behebung.


.. _log:

*log* - Logging in der Browserconsole an-/abschalten

Mit diesem Parameter können die Debug-Logausgaben auf der Browserkonsole ein- und ausgeschaltet werden.
In der Entwicklerversion sind diese standardmäßig eingeschaltet in einem Release aus.

Default: false im Release, true in Entwicklerversion
Options: true (log=true), false (log=false)
7 changes: 4 additions & 3 deletions source/class/cv/Application.js
Expand Up @@ -142,11 +142,12 @@ qx.Class.define("cv.Application",
// run svg4everybody to support SVG sprites in older browsers
svg4everybody();

// support native logging capabilities, e.g. Firebug for Firefox
//noinspection BadExpressionStatementJS,JSHint
cv.log.appender.Native;

// Enable logging in debug variant
if (qx.core.Environment.get("qx.debug")) {
// support native logging capabilities, e.g. Firebug for Firefox
//noinspection BadExpressionStatementJS,JSHint
qx.log.appender.Native;
// support additional cross-browser console. Press F7 to toggle visibility
//noinspection BadExpressionStatementJS,JSHint
qx.log.appender.Console;
Expand Down
12 changes: 12 additions & 0 deletions source/class/cv/Config.js
Expand Up @@ -163,6 +163,11 @@ qx.Class.define('cv.Config', {
*/
reporting: false,

/**
* Set console logging
*/
enableLogging: true,

/**
* Get the structure that is related to this design
* @param design {String?} name of the design
Expand Down Expand Up @@ -264,6 +269,13 @@ qx.Class.define('cv.Config', {
cv.Config.enableCache = req.queryKey.enableCache ? req.queryKey.enableCache === "true" : true;
}

cv.Config.enableLogging = qx.core.Environment.get("html.console");
if (req.queryKey.log === "false") {
cv.Config.enableLogging = false;
} else if (req.queryKey.log === "true") {
cv.Config.enableLogging = true;
}

// "Bug"-Fix for ID: 3204682 "Caching on web server"
// Config isn't a real fix for the problem as that's part of the web browser,
// but
Expand Down
66 changes: 66 additions & 0 deletions source/class/cv/log/appender/Native.js
@@ -0,0 +1,66 @@
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2004-2008 1&1 Internet AG, Germany, http://www.1und1.de
License:
MIT: https://opensource.org/licenses/MIT
See the LICENSE file in the project's top-level directory for details.
Authors:
* Sebastian Werner (wpbasti)
************************************************************************ */

/**
* Processes the incoming log entry and displays it by means of the native
* logging capabilities of the client. Can be disable during runtime
*
* @require(qx.log.appender.Util)
* @require(qx.bom.client.Html)
*/
qx.Bootstrap.define("cv.log.appender.Native",
{
/*
*****************************************************************************
STATICS
*****************************************************************************
*/

statics :
{
/**
* Processes a single log entry
*
* @param entry {Map} The entry to process
*/
process : function(entry)
{
if (cv.Config.enableLogging) {
// Firefox 4's Web Console doesn't support "debug"
var level = console[entry.level] ? entry.level : "log";
if (console[level]) {
var args = qx.log.appender.Util.toText(entry);
console[level](args);
}
}
}
},




/*
*****************************************************************************
DEFER
*****************************************************************************
*/

defer : function(statics) {
qx.log.Logger.register(statics);
}
});

0 comments on commit b7e6bad

Please sign in to comment.