Mercurial > pub > ImplabJs
view 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 |
line wrap: on
line source
define([ "implab/declare", "implab/declare/override" ], function (declare, override) { var cls = declare(null, { _logChannel: null, _logLevel: 1, constructor: function (opts) { if (typeof opts == "object") { if ("logChannel" in opts) this._logChannel = opts.logChannel; if ("logLevel" in opts) this._logLevel = opts.logLevel; } }, getLogChannel: function () { return this._logChannel; }, setLogChannel: function (v) { this._logChannel = v; }, getLogLevel: function () { return this._logLevel; }, setLogLevel: function (v) { this._logLevel = v; }, log: function () { if (this._logChannel && this._logLevel > 2) this._logChannel.log.apply(this._logChannel, arguments); }, warn: function () { if (this._logChannel && this._logLevel > 1) this._logChannel.warn.apply(this._logChannel, arguments); }, error: function () { if (this._logChannel && this._logLevel > 0) this._logChannel.error.apply(this._logChannel, arguments); }, /** * Used to by widgets */ startup: override( /** @this */ function (inherited) { var me = this, parent; if (!me.getLogChannel()) { parent = me; while ((parent = parent.getParent())) { if (parent.getLogChannel) { me.setLogChannel(parent.getLogChannel()); if (parent.getLogLevel) me.setLogLevel(parent.getLogLevel()); break; } } } return inherited(); }) }); return cls; });