How do I turn off the console logging in App Engine Channel API?

十年热恋 提交于 2019-12-07 20:13:24

问题


I've implemented the Channel API w/ persistence. When I make a channel and connect the socket (this is on the real app, not the local dev_appserver), Firebug goes nuts with log messages. I want to turn these off so I can see my OWN logs but cant find any documentation on how to disable the Channel API console logging.

one thing I'm probably doing differently than most is that I'm connecting cross-domain... which the Channel API supports (note the first message in the stream... if you can view that pic)

Does anyone know?


UPDATE

I finally realized that my code was creating two channels and trying to open/connect them both at the same time... and that was why I was getting a flood of messages. I didn't mean to do this (I know the rules: https://developers.google.com/appengine/docs/python/channel/overview#Caveats )... it was a bug... and once I fixed it, the messages went back to manageable level.

yay


回答1:


There doesn't appear to be a way to shutoff the Firebug timeStamp log. One way to solve this problem is to edit the code and remove this functionality yourself:

Unpack the extension to a directory in your Mozilla Firefox Profile:

Change directory to your Firefox profile extensions directory. On Ubuntu, this would be something like this:

cd ~/.mozilla/firefox/{random-string}/extensions/

The Firebug extension is identified by firebug@software.joehewitt.com.xpi. Create a new directory of the same name, but without the .xpi, and move the XPI into that directory:

mkdir firebug@software.joehewitt.com
mv firebug@software.joehewitt.com.xpi firebug@software.joehewitt.com

Next, change directories to your newly created Firebug directory, and unpack the extension:

cd firebug@software.joehewitt.com
unzip firebug@software.joehewitt.com.xpi

All of the files should be unpacked so that the extension's directories are in the current directory. Your file structure will look something like this:

$: ~/.mozilla/firefox/{random-string}/extensions/firebug@software.joehewitt.com$ l
chrome.manifest  defaults/  firebug@software.joehewitt.com.xpi  install.rdf  locale/   skin/
content/         docs/      icons/                              license.txt  modules/

$: ~/.mozilla/firefox/ghlfe0bb.ff5.0/extensions/firebug@software.joehewitt.com$

Open consoleExposed.js in your text editor:

Next, change to the content/firebug/console directory:

cd content/firebug/console

Edit the consoleExposed.js file using your favorite editor:

vim consoleExposed.js

Disable console.timeStamp:

On or near line 215, you'll see the following function:

console.timeStamp = function(label)
{  
    label = label || "";

    if (FBTrace.DBG_CONSOLE)
        FBTrace.sysout("consoleExposed.timeStamp; " + label);

    var now = new Date();
    Firebug.NetMonitor.addTimeStamp(context, now.getTime(), label);

    var formattedTime = now.getHours() + ":" + now.getMinutes() + ":" +
        now.getSeconds() + "." + now.getMilliseconds();
    return logFormatted([formattedTime, label], "timeStamp");
};

Right after the first curly-brace, force the function to return nothing:

console.timeStamp = function(label)
{   return ;   // disable timestamp by returning
    label = label || "";

    if (FBTrace.DBG_CONSOLE)

Restart Firefox and enjoy a world without timeStamp:

After the edits, restart Firebug. You should no longer see the log messages for timeStamp in your console.




回答2:


On the Development server, when using the ChannelAPI, it essentially degrades into a polling implementation instead of using Comet/long-polling. Thus, in your debugger, you see an endless stream of HTTP requests made to the server to continuously and methodically check for updates.

In essence, these are just AJAX requests, or as Firebug would like to think of them, XMLHttpRequests.

Since your browser is responsible for making these requests, the only way to disable them is to click the small arrow on "Console" in Firebug and uncheck the option for logging XMLHttpRequests.

Of course, this also disables logging for all of your other XMLHttpRequests. But it's a small price to pay for the clarity and serenity of a quiet, well-behaved JavaScript console.

For more helpful information on how to make the most of Firebug, see Firebug Tips and Tricks.

NOTE: This works for both users of the Python SDK as well as the Java SDK. (or Go SDK, assuming it has an equivalent ChannelAPI). This is not limited to only Python Appengine.

UPDATE:

From getFirebug:

Creates a time stamp, which can be used together with HTTP traffic timing to measure when a certain piece of code was executed.

The console.timeStamp method was released in Firebug 1.8.0. The same technique described above can also override this Firebug logging method.

console.timeStamp("This is the type of console logging statement that Google is using!");

The above logging statement would produce the olive text. This method can be disabled using the same techniques which were described in the previous section.

However, Google loads the console object inside of a closure, which means that, once Google's code is initialized, the ChannelAPI object has it's own copy of the console object.

In order to disable console.timeStamp, one would need to disable it as the very first action before anything else loads or runs. in other words, we would need to ensure that Google only gets its hands on the disabled console.timeStamp method.

For best results, load this code above the /_ah/channel/jsapi script tag to ensure the console.timeStamp method is disabled before jsapi loads:

if(window.console) console.timeStamp = function(t) { };

NOTE: Because Google invokes Firebug logging in this manner, the only solution may very well in fact require a bug report or feature request that would allow for programmatically disabling this level of logging. Alternatively, the Firebug team could provide a new version of Firebug that includes the ability to explicitly disable timeStamp log statements, similar to how they've done so with Errors, Warnings, XMLHttpRequests, and other log levels.



来源:https://stackoverflow.com/questions/10714958/how-do-i-turn-off-the-console-logging-in-app-engine-channel-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!