提交 6b2a54bb 编写于 作者: fxy060608's avatar fxy060608

fixt(cli): format-log.js(es6=>es5)

上级 27411818
function typof (v) {
const s = Object.prototype.toString.call(v)
var s = Object.prototype.toString.call(v)
return s.substring(8, s.length - 1)
}
export default function formatLog (...args) {
const msgs = args.map((v) => {
const type = Object.prototype.toString.call(v)
export default function formatLog () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key]
}
var msgs = args.map(function (v) {
var type = Object.prototype.toString.call(v)
if (type.toLowerCase() === '[object object]') {
try {
v = '---BEGIN:JSON---' + JSON.stringify(v) + '---END:JSON---'
......@@ -18,7 +23,8 @@ export default function formatLog (...args) {
} else if (v === undefined) {
v = '---UNDEFINED---'
} else {
const vType = typof(v).toUpperCase()
var vType = typof(v).toUpperCase()
if (vType === 'NUMBER' || vType === 'BOOLEAN') {
v = '---BEGIN:' + vType + '---' + v + '---END:' + vType + '---'
} else {
......@@ -26,12 +32,15 @@ export default function formatLog (...args) {
}
}
}
return v
})
let msg = ''
var msg = ''
if (msgs.length > 1) {
const lastMsg = msgs.pop()
var lastMsg = msgs.pop()
msg = msgs.join('---COMMA---')
if (lastMsg.indexOf(' at ') === 0) {
msg += lastMsg
} else {
......@@ -40,5 +49,6 @@ export default function formatLog (...args) {
} else {
msg = msgs[0]
}
return msg
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册