feat: 更新插件基础类库

This commit is contained in:
coding
2017-10-14 07:32:19 +00:00
parent 57554fa644
commit b46da877f6
4 changed files with 63 additions and 29 deletions

View File

@ -4,18 +4,27 @@
/*global base*/
var log = base.getLog().static;
var Level = Java.type('java.util.logging.Level');
var console = {
log: function () {
log.i(Array.prototype.join.call(arguments, ' '));
var Console = function (name) {
this.name = name ? '[' + name + '] ' : '';
Object.defineProperty(this, 'name', {
get: function () {
return this._name;
}.bind(this),
set: function (name) {
this._name = name ? '[' + name + '] ' : '';
}.bind(this)
});
this.log = function () {
log.i(this.name + Array.prototype.join.call(arguments, ' '));
},
warn: function () {
log.w(Array.prototype.join.call(arguments, ' '));
this.warn = function () {
log.w(this.name + Array.prototype.join.call(arguments, ' '));
},
error: function () {
log.log(Level.SEVERE, Array.prototype.join.call(arguments, ' '));
this.error = function () {
log.log(Level.SEVERE, this.name + Array.prototype.join.call(arguments, ' '));
},
debug: function () {
log.d(Array.prototype.join.call(arguments, ' '));
this.debug = function () {
log.d(this.name + Array.prototype.join.call(arguments, ' '));
}
};
global.console = console;
}
global.console = new Console();