Mercurial > pub > ImplabJs
comparison src/implab/components/_LogMixin.js @ 3:00779cb63b12
formatting
author | cin |
---|---|
date | Tue, 06 Jun 2017 19:45:32 +0300 |
parents | fc2517695ee1 |
children |
comparison
equal
deleted
inserted
replaced
2:7d7059d2a810 | 3:00779cb63b12 |
---|---|
1 define([ "dojo/_base/declare" ], | 1 define([ |
2 "implab/declare", "implab/declare/override" | |
3 ], function (declare, override) { | |
4 var cls = declare(null, { | |
5 _logChannel: null, | |
2 | 6 |
3 function(declare) { | 7 _logLevel: 1, |
4 var cls = declare(null, { | |
5 _logChannel : null, | |
6 | 8 |
7 _logLevel : 1, | 9 constructor: function (opts) { |
8 | |
9 constructor : function(opts) { | |
10 if (typeof opts == "object") { | 10 if (typeof opts == "object") { |
11 if ("logChannel" in opts) | 11 if ("logChannel" in opts) |
12 this._logChannel = opts.logChannel; | 12 this._logChannel = opts.logChannel; |
13 if ("logLevel" in opts) | 13 if ("logLevel" in opts) |
14 this._logLevel = opts.logLevel; | 14 this._logLevel = opts.logLevel; |
15 } | 15 } |
16 }, | 16 }, |
17 | 17 |
18 getLogChannel : function() { | 18 getLogChannel: function () { |
19 return this._logChannel; | 19 return this._logChannel; |
20 }, | 20 }, |
21 | 21 |
22 setLogChannel : function(v) { | 22 setLogChannel: function (v) { |
23 this._logChannel = v; | 23 this._logChannel = v; |
24 }, | 24 }, |
25 | 25 |
26 getLogLevel : function() { | 26 getLogLevel: function () { |
27 return this._logLevel; | 27 return this._logLevel; |
28 }, | 28 }, |
29 | 29 |
30 setLogLevel : function(v) { | 30 setLogLevel: function (v) { |
31 this._logLevel = v; | 31 this._logLevel = v; |
32 }, | 32 }, |
33 | 33 |
34 log : function(format) { | 34 log: function () { |
35 if (this._logChannel && this._logLevel > 2) | 35 if (this._logChannel && this._logLevel > 2) |
36 this._logChannel.log.apply(this._logChannel, arguments); | 36 this._logChannel.log.apply(this._logChannel, arguments); |
37 }, | 37 }, |
38 warn : function(format) { | 38 warn: function () { |
39 if (this._logChannel && this._logLevel > 1) | 39 if (this._logChannel && this._logLevel > 1) |
40 this._logChannel.warn.apply(this._logChannel, arguments); | 40 this._logChannel.warn.apply(this._logChannel, arguments); |
41 }, | 41 }, |
42 error : function(format) { | 42 error: function () { |
43 if (this._logChannel && this._logLevel > 0) | 43 if (this._logChannel && this._logLevel > 0) |
44 this._logChannel.error.apply(this._logChannel, arguments); | 44 this._logChannel.error.apply(this._logChannel, arguments); |
45 }, | 45 }, |
46 | 46 |
47 /** | 47 /** |
48 * Used to by widgets | 48 * Used to by widgets |
49 */ | 49 */ |
50 startup : function() { | 50 startup: override( /** @this */ function (inherited) { |
51 var me = this, parent; | 51 var me = this, |
52 parent; | |
52 if (!me.getLogChannel()) { | 53 if (!me.getLogChannel()) { |
53 parent = me; | 54 parent = me; |
54 while (parent = parent.getParent()) { | 55 while ((parent = parent.getParent())) { |
55 if (parent.getLogChannel) { | 56 if (parent.getLogChannel) { |
56 me.setLogChannel(parent.getLogChannel()); | 57 me.setLogChannel(parent.getLogChannel()); |
57 if(parent.getLogLevel) | 58 if (parent.getLogLevel) |
58 me.setLogLevel(parent.getLogLevel()); | 59 me.setLogLevel(parent.getLogLevel()); |
59 break; | 60 break; |
60 } | 61 } |
61 } | 62 } |
62 } | 63 } |
63 this.inherited(arguments); | 64 return inherited(); |
64 } | 65 }) |
65 }); | 66 }); |
66 return cls; | 67 return cls; |
67 }); | 68 }); |