<commit_before>import { DotvvmPostbackError } from "../shared-classes";

type LogLevel = "normal" | "verbose";

export const level = getLogLevel();

export function logInfoVerbose(area: string, ...args: any[]) {
    if (compileConstants.debug && level === "verbose") {
        console.log(`%c${area}`, "background-color: #7fdbff", ...args);
    }
}

export function logInfo(area: string, ...args: any[]) {
    console.log(`%c${area}`, "background-color: #f0f0f0", ...args);
}

export function logWarning(area: string, ...args: any[]) {
    console.warn(`%c${area}`, "background-color: #ff851b", ...args);
}

export function logError(area: string, ...args: any[]) {
    console.error(`%c${area}`, "background-color: #ff4136; color: white", ...args);
}

export function logPostBackScriptError(err: any) {
    if (err instanceof DotvvmPostbackError) {
        return;     // this was logged or handled in the postback pipeline
    }
    logError("postback", "Uncaught error returned from promise!", err);
}

function getLogLevel() : LogLevel {
    if (compileConstants.debug) {
        var logLevel = window.localStorage.getItem("dotvvm-loglevel");
        if (!logLevel) return "normal";
        if (logLevel === "normal" || logLevel === "verbose") return logLevel;
        <commit_msg>Remove colors handed to console.log as parameters<commit_after>import { DotvvmPostbackError } from "../shared-classes";

type LogLevel = "normal" | "verbose";

export const level = getLogLevel();

export function logInfoVerbose(area: string, ...args: any[]) {
    if (compileConstants.debug && level === "verbose") {
        console.log(`%c${area}`, ...args);
    }
}

export function logInfo(area: string, ...args: any[]) {
    console.log(`%c${area}`, ...args);
}

export function logWarning(area: string, ...args: any[]) {
    console.warn(`%c${area}`, ...args);
}

export function logError(area: string, ...args: any[]) {
    console.error(`%c${area}`, ...args);
}

export function logPostBackScriptError(err: any) {
    if (err instanceof DotvvmPostbackError) {
        return;     // this was logged or handled in the postback pipeline
    }
    logError("postback", "Uncaught error returned from promise!", err);
}

function getLogLevel() : LogLevel {
    if (compileConstants.debug) {
        var logLevel = window.localStorage.getItem("dotvvm-loglevel");
        if (!logLevel) return "normal";
        if (logLevel === "normal" || logLevel === "verbose") return logLevel;
        
{'fraction_non_alphanumeric': 0.17178658043654002, 'fraction_numerical': 0.00444624090541633, 'mean_word_length': 3.634831460674157, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '529202', 'n_tokens_mistral': 761, 'n_tokens_neox': 754, 'n_words': 200}