0
|
1 define([ "dojo/_base/declare" ],
|
|
2
|
|
3 function(declare) {
|
|
4 var cls = declare(null, {
|
|
5 _logChannel : null,
|
|
6
|
|
7 _logLevel : 1,
|
|
8
|
|
9 constructor : function(opts) {
|
|
10 if (typeof opts == "object") {
|
|
11 if ("logChannel" in opts)
|
|
12 this._logChannel = opts.logChannel;
|
|
13 if ("logLevel" in opts)
|
|
14 this._logLevel = opts.logLevel;
|
|
15 }
|
|
16 },
|
|
17
|
|
18 getLogChannel : function() {
|
|
19 return this._logChannel;
|
|
20 },
|
|
21
|
|
22 setLogChannel : function(v) {
|
|
23 this._logChannel = v;
|
|
24 },
|
|
25
|
|
26 getLogLevel : function() {
|
|
27 return this._logLevel;
|
|
28 },
|
|
29
|
|
30 setLogLevel : function(v) {
|
|
31 this._logLevel = v;
|
|
32 },
|
|
33
|
|
34 log : function(format) {
|
|
35 if (this._logChannel && this._logLevel > 2)
|
|
36 this._logChannel.log.apply(this._logChannel, arguments);
|
|
37 },
|
|
38 warn : function(format) {
|
|
39 if (this._logChannel && this._logLevel > 1)
|
|
40 this._logChannel.warn.apply(this._logChannel, arguments);
|
|
41 },
|
|
42 error : function(format) {
|
|
43 if (this._logChannel && this._logLevel > 0)
|
|
44 this._logChannel.error.apply(this._logChannel, arguments);
|
|
45 },
|
|
46
|
|
47 /**
|
|
48 * Used to by widgets
|
|
49 */
|
|
50 startup : function() {
|
|
51 var me = this, parent;
|
|
52 if (!me.getLogChannel()) {
|
|
53 parent = me;
|
|
54 while (parent = parent.getParent()) {
|
|
55 if (parent.getLogChannel) {
|
|
56 me.setLogChannel(parent.getLogChannel());
|
|
57 if(parent.getLogLevel)
|
|
58 me.setLogLevel(parent.getLogLevel());
|
|
59 break;
|
|
60 }
|
|
61 }
|
|
62 }
|
|
63 this.inherited(arguments);
|
|
64 }
|
|
65 });
|
|
66 return cls;
|
|
67 }); |