當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript logging.info函數代碼示例

本文整理匯總了TypeScript中@src/lib/logging.info函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript info函數的具體用法?TypeScript info怎麽用?TypeScript info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了info函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getrc

export async function getrc(): Promise<string> {
    const res = await sendNativeMsg("getconfig", {})

    if (res.content && !res.error) {
        logger.info(`Successfully retrieved fs config:\n${res.content}`)
        return res.content
    } else {
        // Have to make this a warning as async exceptions apparently don't get caught
        logger.info(`Error in retrieving config: ${res.error}`)
    }
}
開發者ID:antonva,項目名稱:tridactyl,代碼行數:11,代碼來源:native.ts

示例2: applyWithTmpTextArea

 applyWithTmpTextArea(scratchpad => {
     scratchpad.value = content
     scratchpad.select()
     if (document.execCommand("Copy")) {
         // // todo: Maybe we can consider to using some logger and show it with status bar in the future
         logger.info("set clipboard:", scratchpad.value)
     } else throw "Failed to copy!"
 })
開發者ID:antonva,項目名稱:tridactyl,代碼行數:8,代碼來源:commandline_frame.ts

示例3: sendNativeMsg

/**
 * Posts using the one-time message API; native is killed after message returns
 */
async function sendNativeMsg(
    cmd: MessageCommand,
    opts: object,
    quiet = false,
): Promise<MessageResp> {
    const send = Object.assign({ cmd }, opts)
    let resp
    logger.info(`Sending message: ${JSON.stringify(send)}`)

    try {
        resp = await browserBg.runtime.sendNativeMessage(NATIVE_NAME, send)
        logger.info(`Received response:`, resp)
        return resp as MessageResp
    } catch (e) {
        if (!quiet) {
            throw new Error(
                "Failed to send message to native messenger. If it is correctly installed (run `:native`), please report this bug on https://github.com/tridactyl/tridactyl/issues .",
            )
        }
    }
}
開發者ID:antonva,項目名稱:tridactyl,代碼行數:24,代碼來源:native.ts

示例4: clobberCSP

export function clobberCSP(response) {
    const headers = response.responseHeaders
    const cspHeader = headers.find(
        header => header.name.toLowerCase() === "content-security-policy",
    )

    if (cspHeader !== undefined) {
        const policy = new DefaultMap<string, Set<string>>(
            () => new Set(),
            csp.parse(cspHeader.value),
        )
        logger.info(
            "given CSP",
            cspHeader.value,
            "parsed CSP",
            policy,
            "reserialized CSP",
            csp.serialize(policy),
        )
        policy.delete("sandbox")

        // Loosen style-src directive if it or default-src are present.
        if (policy.has("default-src") && !policy.has("style-src")) {
            policy.set("style-src", policy.get("default-src"))
        }
        if (policy.has("style-src")) {
            policy
                .get("style-src")
                .add("'unsafe-inline'")
                .add("'self'")
        }

        // Replace old CSP
        cspHeader.value = csp.serialize(policy)
        logger.info("new CSP", cspHeader.value, "parsed as", policy)
        return { responseHeaders: headers }
    } else {
        return {}
    }
}
開發者ID:antonva,項目名稱:tridactyl,代碼行數:40,代碼來源:requests.ts

示例5: getNativeMessengerVersion

export async function getNativeMessengerVersion(
    quiet = false,
): Promise<number> {
    const res = await sendNativeMsg("version", {}, quiet)
    if (res === undefined) {
        if (quiet) return undefined
        throw `Error retrieving version: ${res.error}`
    }
    if (res.version && !res.error) {
        logger.info(`Native version: ${res.version}`)
        return res.version
    }
}
開發者ID:antonva,項目名稱:tridactyl,代碼行數:13,代碼來源:native.ts

示例6: run

export async function run(command: string, content = "") {
    const msg = await sendNativeMsg("run", { command, content })
    logger.info(msg)
    return msg
}
開發者ID:antonva,項目名稱:tridactyl,代碼行數:5,代碼來源:native.ts


注:本文中的@src/lib/logging.info函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。