annotate src/implab/components/_LogMixin.js @ 5:3d124d0b9078

improved declare/override, added override.before, override.after, override.hide, inherited.arguments.
author cin
date Fri, 16 Jun 2017 02:14:25 +0300
parents 00779cb63b12
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
1 define([
00779cb63b12 formatting
cin
parents: 0
diff changeset
2 "implab/declare", "implab/declare/override"
00779cb63b12 formatting
cin
parents: 0
diff changeset
3 ], function (declare, override) {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
4 var cls = declare(null, {
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
5 _logChannel: null,
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
6
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
7 _logLevel: 1,
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
8
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
9 constructor: function (opts) {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
10 if (typeof opts == "object") {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
11 if ("logChannel" in opts)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
12 this._logChannel = opts.logChannel;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
13 if ("logLevel" in opts)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
14 this._logLevel = opts.logLevel;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
15 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
16 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
17
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
18 getLogChannel: function () {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
19 return this._logChannel;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
20 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
21
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
22 setLogChannel: function (v) {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
23 this._logChannel = v;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
24 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
25
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
26 getLogLevel: function () {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
27 return this._logLevel;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
28 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
29
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
30 setLogLevel: function (v) {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
31 this._logLevel = v;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
32 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
33
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
34 log: function () {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
35 if (this._logChannel && this._logLevel > 2)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
36 this._logChannel.log.apply(this._logChannel, arguments);
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
37 },
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
38 warn: function () {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
39 if (this._logChannel && this._logLevel > 1)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
40 this._logChannel.warn.apply(this._logChannel, arguments);
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
41 },
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
42 error: function () {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
43 if (this._logChannel && this._logLevel > 0)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
44 this._logChannel.error.apply(this._logChannel, arguments);
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
45 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
46
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
47 /**
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
48 * Used to by widgets
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
49 */
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
50 startup: override( /** @this */ function (inherited) {
00779cb63b12 formatting
cin
parents: 0
diff changeset
51 var me = this,
00779cb63b12 formatting
cin
parents: 0
diff changeset
52 parent;
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
53 if (!me.getLogChannel()) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
54 parent = me;
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
55 while ((parent = parent.getParent())) {
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
56 if (parent.getLogChannel) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
57 me.setLogChannel(parent.getLogChannel());
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
58 if (parent.getLogLevel)
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
59 me.setLogLevel(parent.getLogLevel());
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
60 break;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
61 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
62 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
63 }
3
00779cb63b12 formatting
cin
parents: 0
diff changeset
64 return inherited();
00779cb63b12 formatting
cin
parents: 0
diff changeset
65 })
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
66 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
67 return cls;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
68 });