You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

48 lines
1.4 KiB

import { t as toTypeString, a as toRawType } from "./shared.esm-bundler.js";
function isDebugMode() {
return typeof __channelId__ === "string" && __channelId__;
}
function jsonStringifyReplacer(k, p) {
switch (toRawType(p)) {
case "Function":
return "function() { [native code] }";
default:
return p;
}
}
function normalizeLog(type, filename, args) {
if (isDebugMode()) {
args.push(filename.replace("at ", "uni-app:///"));
return console[type].apply(console, args);
}
const msgs = args.map(function(v) {
const type2 = toTypeString(v).toLowerCase();
if (["[object object]", "[object array]", "[object module]"].indexOf(type2) !== -1) {
try {
v = "---BEGIN:JSON---" + JSON.stringify(v, jsonStringifyReplacer) + "---END:JSON---";
} catch (e) {
v = type2;
}
} else {
if (v === null) {
v = "---NULL---";
} else if (v === void 0) {
v = "---UNDEFINED---";
} else {
const vType = toRawType(v).toUpperCase();
if (vType === "NUMBER" || vType === "BOOLEAN") {
v = "---BEGIN:" + vType + "---" + v + "---END:" + vType + "---";
} else {
v = String(v);
}
}
}
return v;
});
return msgs.join("---COMMA---") + " " + filename;
}
function formatAppLog(type, filename, ...args) {
const res = normalizeLog(type, filename, args);
res && console[type](res);
}
export { formatAppLog as f };