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