Debian Codegraph @

dojox/app/tests/nestedTestApp/controllers/CustomLogger.js

raw symbols SCIP
1 define(["dojo/_base/declare", "dojo/dom", "dojo/dom-style",
2 "dojo/dom-class", "dojo/dom-attr", "dojo/dom-construct", "dojo/_base/config", "dojo/sniff",
3 "dojox/app/Controller"],
4 function (declare, dom, domStyle, domClass, domAttr, domConstruct, dconfig, has, Controller){
5 // module:
6 // dapp/tests/nestedTestApp/controllers/CustomLogger
7 // summary:
8 // A custom logger to handle a special case to only log messages for transitions
9 // It will replace the app.log function with the one in this controller
10 //
11 return declare(Controller, {
12
13 constructor: function (app){
14 // summary:
15 // bind "app-initLayout", "app-layoutView" and "app-resize" events on application instance.
16 //
17 // app:
18 // dojox/app application instance.
19 // dojo mobile events instead
20 app.appLogging=app.appLogging || {};
21 app.appLogging.loggingList=app.appLogging.loggingList || [];
22
23 has.add("app-log-api", ((dconfig["app"] || {}).debugApp) || app.appLogging["logAll"]);
24 has.add("app-log-partial", app.appLogging.loggingList.length > 0);
25
26 if(has("app-log-api") || has("app-log-partial")){
27 app.log=function (){
28 // summary:
29 // If config is set to turn on app logging, then log msg to the console
30 //
31 // arguments:
32 // the message to be logged,
33 // all but the last argument will be treated as Strings and be concatenated together,
34 // the last argument can be an object it will be added as an argument to the console.log
35 var msg="";
36 if(app.appLogging.logTimeStamp){
37 msg=msg + new Date().getTime() + " ";
38 }
39 if(has("app-log-api") || app.appLogging["logAll"]){ // log all messages
40 try{
41 for(var i=0; i < arguments.length - 1; i++){
42 msg=msg + arguments[i] + " ";
43 }
44 console.log(msg, arguments[arguments.length - 1]);
45 } catch (e){
46 }
47 } else if(has("app-log-partial")){ // only log specific things
48 try{
49 if(app.appLogging.loggingList.indexOf(arguments[0]) > -1){ // if the 1st arg is in the loggingList log it
50 for(var i=2; i < arguments.length - 1; i++){
51 msg=msg + arguments[i];
52 }
53 console.log(msg, arguments[arguments.length - 1]);
54 }
55 } catch (e){
56 }
57
58 }
59 };
60 }
61 }
62 });
63 });