mirror of
https://github.com/liriliri/eruda.git
synced 2026-05-20 08:47:20 +08:00
Dev: Support multiple console log arguments
This commit is contained in:
@@ -26,10 +26,10 @@ export default class Console extends Tool
|
|||||||
var log = this._log,
|
var log = this._log,
|
||||||
winConsole = window.console;
|
winConsole = window.console;
|
||||||
|
|
||||||
winConsole.log = function (msg) { log.log(msg) };
|
winConsole.log = function () { log.log.apply(log, arguments) };
|
||||||
winConsole.error = function (msg) { log.error(msg) };
|
winConsole.error = function (msg) { log.error(msg) };
|
||||||
winConsole.info = function (msg) { log.info(msg) };
|
winConsole.info = function () { log.info.apply(log, arguments) };
|
||||||
winConsole.warn = function (msg) { log.warn(msg) };
|
winConsole.warn = function () { log.warn.apply(log, arguments) };
|
||||||
winConsole.dir = function (obj) { log.dir(obj) };
|
winConsole.dir = function (obj) { log.dir(obj) };
|
||||||
winConsole.time = function (name) { log.time(name) };
|
winConsole.time = function (name) { log.time(name) };
|
||||||
winConsole.timeEnd = function (name) { log.timeEnd(name) };
|
winConsole.timeEnd = function (name) { log.timeEnd(name) };
|
||||||
|
|||||||
@@ -50,6 +50,18 @@ function transMsg(msg)
|
|||||||
return util.escape(msg);
|
return util.escape(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function transMultipleMsg(args)
|
||||||
|
{
|
||||||
|
var ret = [];
|
||||||
|
|
||||||
|
util.each(args, function (val)
|
||||||
|
{
|
||||||
|
ret.push(transMsg(val));
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
function transCode(code)
|
function transCode(code)
|
||||||
{
|
{
|
||||||
return code.replace(/\n/g, '<br/>').replace(/ /g, ' ');
|
return code.replace(/\n/g, '<br/>').replace(/ /g, ' ');
|
||||||
@@ -135,9 +147,9 @@ export default class Log extends util.Emitter
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
log(msg)
|
log()
|
||||||
{
|
{
|
||||||
msg = transMsg(msg);
|
var msg = transMultipleMsg(arguments);
|
||||||
|
|
||||||
this._logs.push({
|
this._logs.push({
|
||||||
type: 'log',
|
type: 'log',
|
||||||
@@ -183,9 +195,9 @@ export default class Log extends util.Emitter
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
info(msg)
|
info()
|
||||||
{
|
{
|
||||||
msg = transMsg(msg);
|
var msg = transMultipleMsg(arguments);
|
||||||
|
|
||||||
this._logs.push({
|
this._logs.push({
|
||||||
type: 'info',
|
type: 'info',
|
||||||
@@ -196,9 +208,9 @@ export default class Log extends util.Emitter
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
warn(msg)
|
warn()
|
||||||
{
|
{
|
||||||
msg = transMsg(msg);
|
var msg = transMultipleMsg(arguments);
|
||||||
|
|
||||||
this._logs.push({
|
this._logs.push({
|
||||||
type: 'warn',
|
type: 'warn',
|
||||||
|
|||||||
@@ -19,5 +19,13 @@ export default [
|
|||||||
util.evalCss(borderCss);
|
util.evalCss(borderCss);
|
||||||
},
|
},
|
||||||
desc: 'Add color borders to all elements'
|
desc: 'Add color borders to all elements'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Refresh Page',
|
||||||
|
fn: function ()
|
||||||
|
{
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
desc: 'Refresh current page'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
Reference in New Issue
Block a user