annotate src/implab/components/_LogMixin.js @ 0:fc2517695ee1

Initial commit, draft import of existing work
author cin
date Thu, 01 Jun 2017 13:20:03 +0300
parents
children 00779cb63b12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
1 define([ "dojo/_base/declare" ],
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
2
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
3 function(declare) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
4 var cls = declare(null, {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
5 _logChannel : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
6
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
7 _logLevel : 1,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
8
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
9 constructor : function(opts) {
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
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
18 getLogChannel : function() {
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
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
22 setLogChannel : function(v) {
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
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
26 getLogLevel : function() {
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
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
30 setLogLevel : function(v) {
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
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
34 log : function(format) {
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 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
38 warn : function(format) {
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 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
42 error : function(format) {
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 */
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
50 startup : function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
51 var me = this, parent;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
52 if (!me.getLogChannel()) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
53 parent = me;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
54 while (parent = parent.getParent()) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
55 if (parent.getLogChannel) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
56 me.setLogChannel(parent.getLogChannel());
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
57 if(parent.getLogLevel)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
58 me.setLogLevel(parent.getLogLevel());
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
59 break;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
60 }
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 this.inherited(arguments);
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
64 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
65 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
66 return cls;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
67 });