123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Debug</title>
- <script type="text/javascript" src="../base.js"></script>
- <script type="text/javascript">
- goog.require('goog.debug');
- goog.require('goog.debug.FancyWindow');
- goog.require('goog.log');
-
- var Person = function(name, age) {
- this.name_ = name;
- this.age_ = age;
- this.address_ = null;
- this.kids_ = [];
-
- this.setAddress = function(address) {
- this.address_ = address;
- }
-
- this.addChild = function(child) {
- this.kids_.push(child);
- }
-
- this.toString = function() {
- return 'Person name: ' + this.name_ + ' Age: ' + this.age_;
- }
- }
-
- var demoDebug = function() {
-
- var debugWindow = new goog.debug.FancyWindow('main');
- debugWindow.setEnabled(true);
- debugWindow.init();
-
- var theLogger = goog.log.getLogger('demo');
- goog.log.info(theLogger, 'Logging examples');
-
- var someone = {'name': 'joe',
- 'age': 33,
- 'gender': 'm',
- 'kids': ['jen', 'sam', 'oliver'],
- 'address': '233 Great Road, Axtonhammer, MD'};
-
- goog.log.info(theLogger, someone);
-
- goog.log.info(theLogger, 'Person: '+ goog.debug.expose(someone));
-
- var pObj = new Person('fred', 2);
-
- pObj.addChild(someone);
- pObj.setAddress('1 broadway, ny, ny');
-
- goog.log.info(theLogger, 'toString: '+ pObj);
-
- goog.log.info(theLogger, 'expose (no functions): ' + goog.debug.expose(pObj));
-
- goog.log.info(theLogger, 'expose (no functions): ' + goog.debug.expose(pObj, false));
-
- goog.log.info(theLogger, 'expose (w/functions): ' + goog.debug.expose(pObj, true));
-
- goog.log.info(theLogger, 'deepExpose (no functions): '+ goog.debug.deepExpose(pObj));
-
- goog.log.info(theLogger, 'deepExpose (no functions): '+
- goog.debug.deepExpose(pObj, false));
- goog.log.info(theLogger, 'deepExpose (w/functions): '+
- goog.debug.deepExpose(pObj, true));
- goog.log.log(theLogger, goog.log.Level.SHOUT, 'shout');
- goog.log.error(theLogger, 'severe');
- goog.log.warning(theLogger, 'warning');
- goog.log.info(theLogger, 'info');
- goog.log.fine(theLogger, 'fine');
- }
- </script>
- <body>
- Look in the log window for debugging examples.
- </body>
- <script>
-
- demoDebug();
- </script>
- </html>
|