function printStack(){
    const stack = new Error().stack;
    console.log("调用堆栈:",stack);
}

const originalConsoleLog = console.log;

function isHighSurrogate(codeUnit) {
    return codeUnit >= 0xD800 && codeUnit <= 0xDBFF;
}

function isLowSurrogate(codeUnit) {
    return codeUnit >= 0xDC00 && codeUnit <= 0xDFFF;
}

function splitAndPrintString(str, maxSize) {
    // if(str.indexOf(`{"optionInfo":[{"amount`)!=-1){
    //     printStack();
    // }
    let strLength = str.length;
    for (let i = 0; i < strLength; i += maxSize) {
        let end = i + maxSize;

        // 确保不要在代理对中间拆分
        if (end < str.length && isHighSurrogate(str.charCodeAt(end - 1)) && isLowSurrogate(str.charCodeAt(end))) {
            end++;
        }

        if (strLength > maxSize) {//超过1页
            if (i === 0) { // 第一段
                originalConsoleLog(str.slice(i, end), "__>>__");
            } else if (end >= strLength) { // 最后一段
                originalConsoleLog("__<<__", str.slice(i, end));
            } else { // 中间的段
                originalConsoleLog("__<<__", str.slice(i, end), "__>>__");
            }
        } else {
            originalConsoleLog(str.slice(i, end));
        }
    }
}

//重新定义console.log方法
console.log = function (...args) {
    const maxChunkSize = 800; // 设定最大字符数,可根据需要调整

    // 将所有参数转换为字符串并拼接
    const combinedString = args.map(arg => {
        if (typeof arg === 'object') {
            try {
                return JSON.stringify(arg);
            } catch (e) {
                return "啊啊啊啊啊,解析失败了" + e.message;
            }
        } else {
            return String(arg);
        }
    }).join(' ');

    // 分段打印处理过的字符串
    splitAndPrintString(combinedString, maxChunkSize);
};