50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
|
function toString(message) {
|
||
|
if (message instanceof Function) {
|
||
|
return message.toString();
|
||
|
}
|
||
|
else if (message instanceof Object) {
|
||
|
try {
|
||
|
return JSON.stringify(message);
|
||
|
}
|
||
|
catch (e) {
|
||
|
return message.toString();
|
||
|
}
|
||
|
}
|
||
|
else if (message === undefined) {
|
||
|
return "undefined";
|
||
|
}
|
||
|
else {
|
||
|
return message.toString();
|
||
|
}
|
||
|
}
|
||
|
export function log(...args) {
|
||
|
let out = "";
|
||
|
for (let i = 0; i < arguments.length; i++) {
|
||
|
if (i > 0) {
|
||
|
out += ',';
|
||
|
}
|
||
|
out += toString(arguments[i]);
|
||
|
}
|
||
|
nativeLog('d', out);
|
||
|
}
|
||
|
export function loge(...message) {
|
||
|
let out = "";
|
||
|
for (let i = 0; i < arguments.length; i++) {
|
||
|
if (i > 0) {
|
||
|
out += ',';
|
||
|
}
|
||
|
out += toString(arguments[i]);
|
||
|
}
|
||
|
nativeLog('e', out);
|
||
|
}
|
||
|
export function logw(...message) {
|
||
|
let out = "";
|
||
|
for (let i = 0; i < arguments.length; i++) {
|
||
|
if (i > 0) {
|
||
|
out += ',';
|
||
|
}
|
||
|
out += toString(arguments[i]);
|
||
|
}
|
||
|
nativeLog('w', out);
|
||
|
}
|