PDA

View Full Version : How to log messages?



bteixeira
28 Feb 2012, 4:04 AM
Hi there

I need to log some messages to the console while in development, but don't want them to show up when in production. I found Ext.log() which seems perfect (http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-log)

However, it doesn't seem to do anything! There is a function defined in ext-all-debug-w-comments_extjs4.js but it's empty, in spite of all the JSdoc. I did find the function correctly implemented in extras_extjs4.js, but I can't find any documentation about this file ANYWHERE.

Am I supposed to include extras_extjs4? Shouldn't the function be implemented in ext-debug like the documentation says?

Thanks

friend
28 Feb 2012, 4:13 AM
The documentation appears to be fairly clear. Are any of the items highlighted below working for you?


Logs a message. If a console is present it will be used. On Opera, the method "opera.postError" is called. In other cases, the message is logged to an array "Ext.log.out". An attached debugger can watch this array and view the log. The log buffer is limited to a maximum of "Ext.log.max" entries (defaults to 250). The Ext.log.out array can also be written to a popup window by entering the following in the URL bar (a "bookmarklet"):
javascript:void(Ext.log.show());



Note that you may have to use one of the 'dev' builds of ExtJs. I tested with ext-all-dev.js and it seems to work.

bteixeira
28 Feb 2012, 4:24 AM
Nothing happens. And nothing can happen because the log() function in ext-all-debug-w-comments is empty:


log : function (message) {
},

Meaning, in Firefox I step into the Ext.log() call, and it jumps to that function, which is in ext-all-w-comments, and it's empty.

bteixeira
28 Feb 2012, 6:56 AM
Ok I got it.

While in development, the file included should be ext-all-dev.js, which implements the function.

http://www.sencha.com/forum/showthread.php?132386-FIXED-EXTJSIV-2102-lt-debug-gt-code&p=606710&viewfull=1#post606710